[Scummvm-git-logs] scummvm master -> 39b2209a8021d3cc3c58551d6b8e1d0604813790
antoniou79
a.antoniou79 at gmail.com
Sat Jul 10 16:18:09 UTC 2021
This automated email contains information about 2 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
c35705e7bc BLADERUNNER: Fix Maggie sleep wakeup animations
39b2209a80 BLADERUNNER: Add proper balance to Maggie sounds
Commit: c35705e7bc8ccd7cf09ce120b474de2ddd4d3554
https://github.com/scummvm/scummvm/commit/c35705e7bc8ccd7cf09ce120b474de2ddd4d3554
Author: antoniou79 (a.antoniou79 at gmail.com)
Date: 2021-07-10T19:15:41+03:00
Commit Message:
BLADERUNNER: Fix Maggie sleep wakeup animations
Also minor cleanup of the code for Maggie's AI
Changed paths:
engines/bladerunner/script/ai/maggie.cpp
engines/bladerunner/script/ai_script.h
diff --git a/engines/bladerunner/script/ai/maggie.cpp b/engines/bladerunner/script/ai/maggie.cpp
index 4d25116286..bea2bb5ca3 100644
--- a/engines/bladerunner/script/ai/maggie.cpp
+++ b/engines/bladerunner/script/ai/maggie.cpp
@@ -46,8 +46,8 @@ enum kMaggieStates {
};
AIScriptMaggie::AIScriptMaggie(BladeRunnerEngine *vm) : AIScriptBase(vm) {
- var_45F3F8 = 0;
- var_45F3FC = 0;
+ _varTimesToLoopWhenHappyB = 0;
+ _varTimesToBarkWhenHappyA = 0;
var_45F400 = 0;
var_45F404 = 0;
var_45F408 = 0;
@@ -58,8 +58,8 @@ void AIScriptMaggie::Initialize() {
_animationFrame = 0;
_animationStateNext = 0;
_animationNext = 0;
- var_45F3F8 = 0;
- var_45F3FC = 0;
+ _varTimesToLoopWhenHappyB = 0;
+ _varTimesToBarkWhenHappyA = 0;
var_45F400 = 0; // only assigned to 0. Never checked. Unused.
var_45F404 = 0; // only assigned to 0. Never checked. Unused.
var_45F408 = 0; // only assigned to 0. Never checked. Unused.
@@ -199,12 +199,12 @@ void AIScriptMaggie::ClickedByPlayer() {
return; // true
}
- if (goal == 10) {
+ if (goal == kGoalMaggieMA02SitDown) {
Actor_Change_Animation_Mode(kActorMaggie, kAnimationModeIdle);
return; // true
}
- if (goal == 11) {
+ if (goal == kGoalMaggieMA02Sleep) {
Actor_Change_Animation_Mode(kActorMaggie, 54);
return; // true
}
@@ -329,12 +329,19 @@ bool AIScriptMaggie::GoalChanged(int currentGoalNumber, int newGoalNumber) {
return true;
case kGoalMaggieMA02Sleep:
+ // When setting Maggie's *goal* to sleep, we expect it to be enforced
+ // However, Actor_Change_Animation_Mode is not enforceable and could be ignored.
+ // The goal change here is *NOT* done in order to play the animation.
+ // It is to set the animation State, and by explicitly setting it, it overrides playing the animation transition.
+ // Actor_Change_Animation_Mode) is called to store the _animationMode on Maggie's actor object (see: Actor::changeAnimationMode())
Actor_Change_Animation_Mode(kActorMaggie, 55);
- // TODO Why set _animationState and frame explicitly here,
- // when the Actor_Change_Animation_Mode() should take care of it?
- // does this not negate the "transition" animation?
_animationState = kMaggieStateSleeping;
+#if BLADERUNNER_ORIGINAL_BUGS
_animationFrame = 0;
+#else
+ // We actually need the final frame here to avoid Maggie glitching here
+ _animationFrame = Slice_Animation_Query_Number_Of_Frames(kModelAnimationMaggieToggleLaySleepingWakeUp) - 1;
+#endif // BLADERUNNER_ORIGINAL_BUGS
return true;
case 400:
@@ -529,8 +536,8 @@ bool AIScriptMaggie::UpdateAnimation(int *animation, int *frame) {
++_animationFrame;
if (_animationFrame >= Slice_Animation_Query_Number_Of_Frames(kModelAnimationMaggieBarking)) {
_animationFrame = 0;
- --var_45F3F8;
- if (var_45F3F8 <= 0) {
+ --_varTimesToLoopWhenHappyB;
+ if (_varTimesToLoopWhenHappyB <= 0) {
Actor_Change_Animation_Mode(kActorMaggie, kAnimationModeIdle);
*animation = kModelAnimationMaggieStandingIdle;
}
@@ -545,8 +552,8 @@ bool AIScriptMaggie::UpdateAnimation(int *animation, int *frame) {
}
++_animationFrame;
if (_animationFrame >= Slice_Animation_Query_Number_Of_Frames(*animation)) {
- --var_45F3FC;
- if (var_45F3FC <= 0) {
+ --_varTimesToBarkWhenHappyA;
+ if (_varTimesToBarkWhenHappyA <= 0) {
Actor_Change_Animation_Mode(kActorMaggie, kAnimationModeIdle);
*animation = kModelAnimationMaggieStandingIdle;
_animationState = kMaggieStateIdle;
@@ -587,20 +594,11 @@ bool AIScriptMaggie::UpdateAnimation(int *animation, int *frame) {
}
bool AIScriptMaggie::ChangeAnimationMode(int mode) {
- if (mode == kAnimationModeWalk) {
- if (Game_Flag_Query(kFlagMaggieHasBomb)) {
- _animationState = kMaggieStateBombWalk;
- _animationFrame = 0;
- } else {
- _animationState = kMaggieStateWalking;
- _animationFrame = 0;
- }
- return true;
- }
- if (mode == kAnimationModeIdle) {
+ switch (mode) {
+ case kAnimationModeIdle:
if (Game_Flag_Query(kFlagMaggieHasBomb)) {
_animationState = kMaggieStateBombIdle;
- _animationFrame = kMaggieStateIdle;
+ _animationFrame = 0;
} else {
switch (_animationState) {
case kMaggieStateGoingToSleep:
@@ -609,7 +607,7 @@ bool AIScriptMaggie::ChangeAnimationMode(int mode) {
_animationState = kMaggieStateWakingUp;
break;
- case kMaggieStateIdle:
+ case kMaggieStateLayingIdle:
_animationState = kMaggieStateStandingUp;
_animationFrame = 0;
break;
@@ -632,10 +630,18 @@ bool AIScriptMaggie::ChangeAnimationMode(int mode) {
break;
}
}
- return true;
- }
+ break;
+
+ case kAnimationModeWalk:
+ if (Game_Flag_Query(kFlagMaggieHasBomb)) {
+ _animationState = kMaggieStateBombWalk;
+ _animationFrame = 0;
+ } else {
+ _animationState = kMaggieStateWalking;
+ _animationFrame = 0;
+ }
+ break;
- switch (mode) {
case 51:
_animationState = kMaggieStateExploding;
_animationFrame = 0;
@@ -657,7 +663,11 @@ bool AIScriptMaggie::ChangeAnimationMode(int mode) {
if (_animationState > kMaggieStateIdle) {
if (_animationState == kMaggieStateSleeping) {
_animationState = kMaggieStateWakingUp;
+#if BLADERUNNER_ORIGINAL_BUGS
+ // Don't start from frame 0 here, since the animation has to play backwards,
+ // and being on kMaggieStateSleeping state means we are already at the proper (end) frame
_animationFrame = 0;
+#endif // BLADERUNNER_ORIGINAL_BUGS
}
} else {
_animationState = kMaggieStateLayingDown;
@@ -678,7 +688,7 @@ bool AIScriptMaggie::ChangeAnimationMode(int mode) {
_animationFrame = 0;
_animationState = kMaggieStateHappyA;
}
- var_45F3FC = Random_Query(2, 6);
+ _varTimesToBarkWhenHappyA = Random_Query(2, 6);
break;
case 57:
@@ -686,7 +696,7 @@ bool AIScriptMaggie::ChangeAnimationMode(int mode) {
_animationFrame = 0;
_animationState = kMaggieStateHappyB;
}
- var_45F3F8 = Random_Query(2, 6);
+ _varTimesToLoopWhenHappyB = Random_Query(2, 6);
Sound_Play(kSfxDOGTAIL1, 50, 0, 0, 50);
break;
diff --git a/engines/bladerunner/script/ai_script.h b/engines/bladerunner/script/ai_script.h
index 7e74f71cab..5abe228e72 100644
--- a/engines/bladerunner/script/ai_script.h
+++ b/engines/bladerunner/script/ai_script.h
@@ -471,8 +471,8 @@ DECLARE_SCRIPT(FreeSlotB)
END_SCRIPT
DECLARE_SCRIPT(Maggie)
- int var_45F3F8;
- int var_45F3FC;
+ int _varTimesToLoopWhenHappyB;
+ int _varTimesToBarkWhenHappyA;
int var_45F400; // only set to 0. unused
int var_45F404; // only set to 0. unused
int var_45F408; // only set to 0. unused
Commit: 39b2209a8021d3cc3c58551d6b8e1d0604813790
https://github.com/scummvm/scummvm/commit/39b2209a8021d3cc3c58551d6b8e1d0604813790
Author: antoniou79 (a.antoniou79 at gmail.com)
Date: 2021-07-10T19:15:41+03:00
Commit Message:
BLADERUNNER: Add proper balance to Maggie sounds
Changed paths:
engines/bladerunner/actor.cpp
engines/bladerunner/actor.h
engines/bladerunner/script/ai/maggie.cpp
engines/bladerunner/script/ai_script.h
diff --git a/engines/bladerunner/actor.cpp b/engines/bladerunner/actor.cpp
index 3dbcee6c11..aa1c8789a3 100644
--- a/engines/bladerunner/actor.cpp
+++ b/engines/bladerunner/actor.cpp
@@ -1579,9 +1579,12 @@ int Actor::soundVolume() const {
return (35 * CLIP<int>(100 - (dist / 12), 0, 100)) / 100; // map [0..1200] to [35..0]
}
-int Actor::soundPan() const {
+// overrideRange argument was added to allow for more accurate sound balance on occasion (if required)
+int Actor::soundPan(uint8 overrideRange) const {
Vector3 screenPosition = _vm->_view->calculateScreenPosition(_position);
- return (35 * (2 * CLIP<int>(screenPosition.x, 0, 640) - 640)) / 640; // map [0..640] to [-35..35]
+ // By default map [0..640] to [-overrideRange..overrideRange] (default range [-35..35])
+ CLIP<int>(overrideRange, 35, 100);
+ return (overrideRange * (2 * CLIP<int>(screenPosition.x, 0, 640) - 640)) / 640;
}
bool Actor::isObstacleBetween(const Vector3 &target) {
diff --git a/engines/bladerunner/actor.h b/engines/bladerunner/actor.h
index 84a9c913b8..6c98a33822 100644
--- a/engines/bladerunner/actor.h
+++ b/engines/bladerunner/actor.h
@@ -262,7 +262,7 @@ public:
void acquireCluesByRelations();
int soundVolume() const;
- int soundPan() const;
+ int soundPan(uint8 overrideRange = 35) const;
bool isObstacleBetween(const Vector3 &target);
diff --git a/engines/bladerunner/script/ai/maggie.cpp b/engines/bladerunner/script/ai/maggie.cpp
index bea2bb5ca3..39bf9fd4c9 100644
--- a/engines/bladerunner/script/ai/maggie.cpp
+++ b/engines/bladerunner/script/ai/maggie.cpp
@@ -22,6 +22,7 @@
#include "bladerunner/script/ai_script.h"
#include "bladerunner/vector.h"
+#include "bladerunner/actor.h"
namespace BladeRunner {
@@ -48,7 +49,7 @@ enum kMaggieStates {
AIScriptMaggie::AIScriptMaggie(BladeRunnerEngine *vm) : AIScriptBase(vm) {
_varTimesToLoopWhenHappyB = 0;
_varTimesToBarkWhenHappyA = 0;
- var_45F400 = 0;
+ _varMaggieSoundPan = 0;
var_45F404 = 0;
var_45F408 = 0;
}
@@ -60,7 +61,7 @@ void AIScriptMaggie::Initialize() {
_animationNext = 0;
_varTimesToLoopWhenHappyB = 0;
_varTimesToBarkWhenHappyA = 0;
- var_45F400 = 0; // only assigned to 0. Never checked. Unused.
+ _varMaggieSoundPan = 0;
var_45F404 = 0; // only assigned to 0. Never checked. Unused.
var_45F408 = 0; // only assigned to 0. Never checked. Unused.
Actor_Set_Goal_Number(kActorMaggie, kGoalMaggieMA02Default);
@@ -103,13 +104,17 @@ void AIScriptMaggie::TimerExpired(int timer) {
AI_Movement_Track_Append(kActorMaggie, randomWaypointMA02(), 0);
AI_Movement_Track_Repeat(kActorMaggie);
} else {
- Actor_Change_Animation_Mode(kActorMaggie, 54);
+ Actor_Change_Animation_Mode(kActorMaggie, 54); // sitting in place
}
return; //true
}
if (goal == kGoalMaggieMA02SitDown) {
+ // if in process of laying down or already laying down
AI_Countdown_Timer_Reset(kActorMaggie, kActorTimerAIScriptCustomTask0);
+ // Changing animation mode to 55 (sleeping) is effective only if state is at kMaggieStateLayingIdle.
+ // So if current Maggie is currenty in *the process* of laying down,
+ // this won't do anything. But since we reset the timer, it will be effective in a next call.
Actor_Change_Animation_Mode(kActorMaggie, 55);
return; //true
}
@@ -378,7 +383,12 @@ bool AIScriptMaggie::GoalChanged(int currentGoalNumber, int newGoalNumber) {
case kGoalMaggieKP05Explode:
AI_Movement_Track_Flush(kActorMaggie);
Actor_Face_Actor(kActorMcCoy, kActorMaggie, true);
+#if BLADERUNNER_ORIGINAL_BUGS
Sound_Play(kSfxDOGEXPL1, 50, 0, 0, 100);
+#else
+ _varMaggieSoundPan = _vm->_actors[kActorMaggie]->soundPan(75);
+ Sound_Play(kSfxDOGEXPL1, 50, _varMaggieSoundPan, _varMaggieSoundPan, 100);
+#endif // BLADERUNNER_ORIGINAL_BUGS
Actor_Set_Goal_Number(kActorMaggie, kGoalMaggieDead);
Actor_Change_Animation_Mode(kActorMaggie, 51);
if (Actor_Query_Inch_Distance_From_Actor(kActorMcCoy, kActorMaggie) < 144) {
@@ -532,6 +542,7 @@ bool AIScriptMaggie::UpdateAnimation(int *animation, int *frame) {
break;
case kMaggieStateHappyB:
+ // Not actually barking in this case
*animation = kModelAnimationMaggieBarking;
++_animationFrame;
if (_animationFrame >= Slice_Animation_Query_Number_Of_Frames(kModelAnimationMaggieBarking)) {
@@ -545,10 +556,16 @@ bool AIScriptMaggie::UpdateAnimation(int *animation, int *frame) {
break;
case kMaggieStateHappyA:
+ // Barking in this case
*animation = kModelAnimationMaggieBarkingOrHeadUp;
if (_animationFrame == 1) {
// one of kSfxDOGBARK1, kSfxDOGBARK3
+#if BLADERUNNER_ORIGINAL_BUGS
Sound_Play(Random_Query(kSfxDOGBARK1, kSfxDOGBARK3), 50, 0, 0, 50);
+#else
+ _varMaggieSoundPan = _vm->_actors[kActorMaggie]->soundPan(75);
+ Sound_Play(Random_Query(kSfxDOGBARK1, kSfxDOGBARK3), 50, _varMaggieSoundPan, _varMaggieSoundPan, 50);
+#endif // BLADERUNNER_ORIGINAL_BUGS
}
++_animationFrame;
if (_animationFrame >= Slice_Animation_Query_Number_Of_Frames(*animation)) {
@@ -645,7 +662,12 @@ bool AIScriptMaggie::ChangeAnimationMode(int mode) {
case 51:
_animationState = kMaggieStateExploding;
_animationFrame = 0;
+#if BLADERUNNER_ORIGINAL_BUGS
Sound_Play(kSfxDOGHURT1, 50, 0, 0, 50);
+#else
+ _varMaggieSoundPan = _vm->_actors[kActorMaggie]->soundPan(75);
+ Sound_Play(kSfxDOGHURT1, 50, _varMaggieSoundPan, _varMaggieSoundPan, 50);
+#endif // BLADERUNNER_ORIGINAL_BUGS
break;
case kAnimationModeFeeding:
@@ -697,7 +719,16 @@ bool AIScriptMaggie::ChangeAnimationMode(int mode) {
_animationState = kMaggieStateHappyB;
}
_varTimesToLoopWhenHappyB = Random_Query(2, 6);
- Sound_Play(kSfxDOGTAIL1, 50, 0, 0, 50);
+ _varMaggieSoundPan = _vm->_actors[kActorMaggie]->soundPan(75);
+ if (_vm->_cutContent) {
+ Sound_Play(Random_Query(kSfxDOGTAIL1, kSfxDOGTAIL2), 50, _varMaggieSoundPan, _varMaggieSoundPan, 50);
+ } else {
+#if BLADERUNNER_ORIGINAL_BUGS
+ Sound_Play(kSfxDOGTAIL1, 50, 0, 0, 50);
+#else
+ Sound_Play(kSfxDOGTAIL1, 50, _varMaggieSoundPan, _varMaggieSoundPan, 50);
+#endif // BLADERUNNER_ORIGINAL_BUGS
+ }
break;
case 88:
diff --git a/engines/bladerunner/script/ai_script.h b/engines/bladerunner/script/ai_script.h
index 5abe228e72..2a4f1977e7 100644
--- a/engines/bladerunner/script/ai_script.h
+++ b/engines/bladerunner/script/ai_script.h
@@ -473,9 +473,9 @@ END_SCRIPT
DECLARE_SCRIPT(Maggie)
int _varTimesToLoopWhenHappyB;
int _varTimesToBarkWhenHappyA;
- int var_45F400; // only set to 0. unused
- int var_45F404; // only set to 0. unused
- int var_45F408; // only set to 0. unused
+ int _varMaggieSoundPan; // Repurposed - Original: unused only set to 0 (var_45F400)
+ int var_45F404; // only set to 0. unused
+ int var_45F408; // only set to 0. unused
int randomWaypointMA02();
float distanceToActor(int actorId, float x, float y, float z);
More information about the Scummvm-git-logs
mailing list