[Scummvm-git-logs] scummvm master -> 2a0bdd7df8a60c59d96f077d50567460cbf8e814

peterkohaut peterkohaut at users.noreply.github.com
Tue Mar 6 21:17:20 CET 2018


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:
2a0bdd7df8 BLADERUNNER: Added stairs & ladder support


Commit: 2a0bdd7df8a60c59d96f077d50567460cbf8e814
    https://github.com/scummvm/scummvm/commit/2a0bdd7df8a60c59d96f077d50567460cbf8e814
Author: Peter Kohaut (peter.kohaut at gmail.com)
Date: 2018-03-06T21:12:52+01:00

Commit Message:
BLADERUNNER: Added stairs & ladder support

Changed paths:
    engines/bladerunner/game_constants.h
    engines/bladerunner/script/ai/leon.cpp
    engines/bladerunner/script/ai/mccoy.cpp
    engines/bladerunner/script/ai/officer_leary.cpp
    engines/bladerunner/script/ai/runciter.cpp
    engines/bladerunner/script/script.cpp
    engines/bladerunner/script/script.h


diff --git a/engines/bladerunner/game_constants.h b/engines/bladerunner/game_constants.h
index fc04392..4a6d395 100644
--- a/engines/bladerunner/game_constants.h
+++ b/engines/bladerunner/game_constants.h
@@ -569,7 +569,15 @@ enum AnimationModes {
 	kAnimationModeCombatShoot = 6,
 	kAnimationModeCombatWalk = 7,
 	kAnimationModeCombatRun = 8,
-	kAnimationModeFeeding = 52
+	kAnimationModeWalkUp = 44,
+	kAnimationModeWalkDown = 45,
+	kAnimationModeCombatWalkUp = 46,
+	kAnimationModeCombatWalkDown = 47,
+	kAnimationModeFeeding = 52,
+	kAnimationModeClimbUp = 64,
+	kAnimationModeClimbDown = 65,
+	kAnimationModeCombatClimbUp = 66,
+	kAnimationModeCombatClimbDown = 67
 };
 
 enum SceneLoopMode {
diff --git a/engines/bladerunner/script/ai/leon.cpp b/engines/bladerunner/script/ai/leon.cpp
index bc06b0d..fad9da3 100644
--- a/engines/bladerunner/script/ai/leon.cpp
+++ b/engines/bladerunner/script/ai/leon.cpp
@@ -244,7 +244,6 @@ bool AIScriptLeon::GoalChanged(int currentGoalNumber, int newGoalNumber) {
 }
 
 bool AIScriptLeon::UpdateAnimation(int *animation, int *frame) {
-
 	switch (_animationState) {
 	case 10:
 		*animation = 856;
@@ -382,7 +381,7 @@ bool AIScriptLeon::ChangeAnimationMode(int mode) {
 		_animationState = 1;
 		_animationFrame = 0;
 		break;
-	case 3:
+	case kAnimationModeTalk:
 		_animationState = 2;
 		_animationFrame = 0;
 		var_45EDAC = 0;
diff --git a/engines/bladerunner/script/ai/mccoy.cpp b/engines/bladerunner/script/ai/mccoy.cpp
index faecdf9..add613e 100644
--- a/engines/bladerunner/script/ai/mccoy.cpp
+++ b/engines/bladerunner/script/ai/mccoy.cpp
@@ -1313,7 +1313,7 @@ bool AIScriptMcCoy::ChangeAnimationMode(int mode) {
 			}
 		}
 		break;
-	case 3:
+	case kAnimationModeTalk:
 		if (_animationState < 3 || _animationState > 12) {
 			_animationState = 13;
 			_animationStateNext = 3;
@@ -1362,7 +1362,7 @@ bool AIScriptMcCoy::ChangeAnimationMode(int mode) {
 			break;
 		}
 		break;
-	case 5:
+	case kAnimationModeCombatAim:
 		switch (_animationState) {
 		case 17:
 		case 18:
@@ -1571,19 +1571,19 @@ bool AIScriptMcCoy::ChangeAnimationMode(int mode) {
 		_animationFrame = 0;
 		Player_Loses_Control();
 		break;
-	case 44:
+	case kAnimationModeWalkUp:
 		_animationState = 38;
 		_animationFrame = 0;
 		break;
-	case 45:
+	case kAnimationModeWalkDown:
 		_animationState = 39;
 		_animationFrame = 0;
 		break;
-	case 46:
+	case kAnimationModeCombatWalkUp:
 		_animationState = 40;
 		_animationFrame = 0;
 		break;
-	case 47:
+	case kAnimationModeCombatWalkDown:
 		_animationState = 41;
 		_animationFrame = 0;
 		break;
@@ -1631,13 +1631,13 @@ bool AIScriptMcCoy::ChangeAnimationMode(int mode) {
 			_animationState = 70;
 		}
 		break;
-	case 64:
-	case 66:
+	case kAnimationModeClimbUp:
+	case kAnimationModeCombatClimbUp:
 		_animationState = 42;
 		_animationFrame = 0;
 		break;
-	case 65:
-	case 67:
+	case kAnimationModeClimbDown:
+	case kAnimationModeCombatClimbDown:
 		_animationState = 43;
 		_animationFrame = 0;
 		break;
diff --git a/engines/bladerunner/script/ai/officer_leary.cpp b/engines/bladerunner/script/ai/officer_leary.cpp
index d51b7d8..b18ba08 100644
--- a/engines/bladerunner/script/ai/officer_leary.cpp
+++ b/engines/bladerunner/script/ai/officer_leary.cpp
@@ -941,7 +941,7 @@ bool AIScriptOfficerLeary::ChangeAnimationMode(int mode) {
 		_animationState = 4;
 		_animationFrame = 0;
 		break;
-	case 3:
+	case kAnimationModeTalk:
 		if (_animationState == 1) {
 			_animationState = 2;
 			_animationStateNext = 11;
@@ -979,7 +979,7 @@ bool AIScriptOfficerLeary::ChangeAnimationMode(int mode) {
 			break;
 		}
 		break;
-	case 6:
+	case kAnimationModeCombatShoot:
 		_animationState = 24;
 		_animationFrame = 0;
 		break;
@@ -1140,19 +1140,19 @@ bool AIScriptOfficerLeary::ChangeAnimationMode(int mode) {
 	case 28:
 		Game_Flag_Set(199);
 		break;
-	case 44:
+	case kAnimationModeWalkUp:
 		_animationState = 5;
 		_animationFrame = 0;
 		break;
-	case 45:
+	case kAnimationModeWalkDown:
 		_animationState = 6;
 		_animationFrame = 0;
 		break;
-	case 46:
+	case kAnimationModeCombatWalkUp:
 		_animationState = 9;
 		_animationFrame = 0;
 		break;
-	case 47:
+	case kAnimationModeCombatWalkDown:
 		_animationState = 10;
 		_animationFrame = 0;
 		break;
diff --git a/engines/bladerunner/script/ai/runciter.cpp b/engines/bladerunner/script/ai/runciter.cpp
index 18b7ae9..afefa43 100644
--- a/engines/bladerunner/script/ai/runciter.cpp
+++ b/engines/bladerunner/script/ai/runciter.cpp
@@ -500,7 +500,7 @@ bool AIScriptRunciter::ChangeAnimationMode(int mode) {
 			_animationNext = 526;
 		}
 		break;
-	case 3:
+	case kAnimationModeTalk:
 		if (_animationState  != 0) {
 			_animationState = 2;
 			_animationFrame = 0;
diff --git a/engines/bladerunner/script/script.cpp b/engines/bladerunner/script/script.cpp
index 528dc2f..cbea72e 100644
--- a/engines/bladerunner/script/script.cpp
+++ b/engines/bladerunner/script/script.cpp
@@ -553,16 +553,90 @@ void ScriptBase::Actor_Force_Stop_Walking(int actorId) {
 	warning("Loop_Actor_Travel_Stairs(%d)", actorId);
 }
 
-bool ScriptBase::Loop_Actor_Travel_Stairs(int actorId, int a2, int a3, int a4) {
-	//TODO
-	warning("Loop_Actor_Travel_Stairs(%d, %d, %d, %d)", actorId, a2, a3, a4);
-	return false;
+void ScriptBase::Loop_Actor_Travel_Stairs(int actorId, int stepCount, bool up, int animationModeEnd) {
+	_vm->gameWaitForActive();
+
+	Player_Loses_Control();
+
+	Actor *actor = _vm->_actors[actorId];
+
+	int animationModeWalk = 0;
+	if (actor->inCombat()) {
+		animationModeWalk = up ? kAnimationModeCombatWalkUp : kAnimationModeCombatWalkDown;
+		if (animationModeEnd == kAnimationModeIdle) {
+			animationModeEnd = kAnimationModeCombatIdle;
+		}
+	} else {
+		animationModeWalk = up ? kAnimationModeWalkUp : kAnimationModeWalkDown;
+	}
+	actor->changeAnimationMode(animationModeWalk, false);
+
+	int stairsHeight = stepCount * 9 * (up ? 1 : -1);
+	float targetY = actor->getY() + stairsHeight;
+
+	bool immunityToObstacles = actor->isImmuneToObstacles();
+	actor->setImmunityToObstacles(true);
+	do {
+		_vm->gameTick();
+		if (up) {
+			if (targetY <= actor->getY()) {
+				break;
+			}
+		} else {
+			if (targetY >= actor->getY()) {
+				break;
+			}
+		}
+	} while (true);
+	actor->setImmunityToObstacles(immunityToObstacles);
+
+	actor->setAtXYZ(Vector3(actor->getX(), targetY, actor->getZ()), actor->getFacing(), true, false, false);
+	actor->changeAnimationMode(animationModeEnd, false);
+
+	Player_Gains_Control();
 }
 
-bool ScriptBase::Loop_Actor_Travel_Ladder(int actorId, int a2, int a3, int a4) {
-	//TODO
-	warning("Loop_Actor_Travel_Ladder(%d, %d, %d, %d)", actorId,a2,a3,a4);
-	return false;
+void ScriptBase::Loop_Actor_Travel_Ladder(int actorId, int stepCount, bool up, int animationModeEnd) {
+	_vm->gameWaitForActive();
+
+	Player_Loses_Control();
+
+	Actor *actor = _vm->_actors[actorId];
+
+	int animationModeWalk = 0;
+	if (actor->inCombat()) {
+		animationModeWalk = up ? kAnimationModeCombatClimbUp : kAnimationModeCombatClimbDown;
+		if (animationModeEnd == kAnimationModeIdle) {
+			animationModeEnd = kAnimationModeCombatIdle;
+		}
+	} else {
+		animationModeWalk = up ? kAnimationModeClimbUp : kAnimationModeClimbDown;
+	}
+	actor->changeAnimationMode(animationModeWalk, false);
+
+	int ladderHeight = stepCount * 12 * (up ? 1 : -1);
+	float targetY = actor->getY() + ladderHeight;
+
+	bool immunityToObstacles = actor->isImmuneToObstacles();
+	actor->setImmunityToObstacles(true);
+	do {
+		_vm->gameTick();
+		if (up) {
+			if (targetY <= actor->getY()) {
+				break;
+			}
+		} else {
+			if (targetY >= actor->getY()) {
+				break;
+			}
+		}
+	} while (true);
+	actor->setImmunityToObstacles(immunityToObstacles);
+
+	actor->setAtXYZ(Vector3(actor->getX(), targetY, actor->getZ()), actor->getFacing(), true, false, false);
+	actor->changeAnimationMode(animationModeEnd, false);
+
+	Player_Gains_Control();
 }
 
 void ScriptBase::Actor_Clue_Add_To_Database(int actorId, int clueId, int weight, bool clueAcquired, bool unknownFlag, int fromActorId) {
diff --git a/engines/bladerunner/script/script.h b/engines/bladerunner/script/script.h
index ae6e6ee..edfbacd 100644
--- a/engines/bladerunner/script/script.h
+++ b/engines/bladerunner/script/script.h
@@ -109,8 +109,8 @@ protected:
 	void Async_Actor_Walk_To_Waypoint(int actorId, int waypointId, int destinationOffset, bool run);
 	void Async_Actor_Walk_To_XYZ(int actorId, float x, float y, float z, int destinationOffset, bool run);
 	void Actor_Force_Stop_Walking(int actorId);
-	bool Loop_Actor_Travel_Stairs(int actorId, int a2, int a3, int a4);
-	bool Loop_Actor_Travel_Ladder(int actorId, int a2, int a3, int a4);
+	void Loop_Actor_Travel_Stairs(int actorId, int stepCount, bool up, int animationModeEnd);
+	void Loop_Actor_Travel_Ladder(int actorId, int stepCount, bool up, int animationModeEnd);
 	void Actor_Clue_Add_To_Database(int actorId, int clueId, int weight, bool clueAcquired, bool unknownFlag, int fromActorId);
 	void Actor_Clue_Acquire(int actorId, int clueId, bool unknownFlag, int fromActorId);
 	void Actor_Clue_Lose(int actorId, int clueId);





More information about the Scummvm-git-logs mailing list