BLADERUNNER: Fix NR11 pathfinding

Added new method to "remove" bad objects in a scene/nr11

Removed objects, and still there, but they are renamed to "REMOVEDxx" and they won't affect obstacles and paths
This commit is contained in:
Thanasis Antoniou 2019-05-23 15:05:03 +03:00
parent 67a29ad5b3
commit d78dd5c058
4 changed files with 73 additions and 1 deletions

View File

@ -70,7 +70,10 @@ void SceneScriptNR11::SceneLoaded() {
Clickable_Object("CLOTHING02");
Clickable_Object("BOX27");
Clickable_Object("BOX39");
#if BLADERUNNER_ORIGINAL_BUGS
// in our bugfixes this object is removed
Clickable_Object("BOX44");
#endif // BLADERUNNER_ORIGINAL_BUGS
Clickable_Object("DRESS");
Clickable_Object("COATRACK");
Clickable_Object("COLUMN3 DETS");
@ -85,7 +88,10 @@ void SceneScriptNR11::SceneLoaded() {
Combat_Target_Object("CLOTHING02");
Combat_Target_Object("BOX27");
Combat_Target_Object("BOX39");
#if BLADERUNNER_ORIGINAL_BUGS
// in our bugfixes this object is removed
Combat_Target_Object("BOX44");
#endif // BLADERUNNER_ORIGINAL_BUGS
Combat_Target_Object("DRESS");
Combat_Target_Object("COATRACK");
Combat_Target_Object("COLUMN3 DETS");
@ -101,7 +107,10 @@ void SceneScriptNR11::SceneLoaded() {
Unclickable_Object("CLOTHING02");
Unclickable_Object("BOX27");
Unclickable_Object("BOX39");
#if BLADERUNNER_ORIGINAL_BUGS
// in our bugfixes this object is removed
Unclickable_Object("BOX44");
#endif
Unclickable_Object("DRESS");
Unclickable_Object("COATRACK");
Unclickable_Object("COLUMN3 DETS");
@ -125,7 +134,10 @@ bool SceneScriptNR11::ClickedOn3DObject(const char *objectName, bool combatMode)
if (Object_Query_Click("CLOTHING02", objectName)
|| Object_Query_Click("BOX27", objectName)
|| Object_Query_Click("BOX39", objectName)
#if BLADERUNNER_ORIGINAL_BUGS
// in our bugfixes this object is removed
|| Object_Query_Click("BOX44", objectName)
#endif // BLADERUNNER_ORIGINAL_BUGS
|| Object_Query_Click("DRESS", objectName)
|| Object_Query_Click("COATRACK", objectName)
|| Object_Query_Click("COLUMN3 DETS", objectName)
@ -410,7 +422,10 @@ void SceneScriptNR11::untargetEverything() {
Un_Combat_Target_Object("CLOTHING02");
Un_Combat_Target_Object("BOX27");
Un_Combat_Target_Object("BOX39");
#if BLADERUNNER_ORIGINAL_BUGS
// in our bugfixes this object is removed
Un_Combat_Target_Object("BOX44");
#endif // BLADERUNNER_ORIGINAL_BUGS
Un_Combat_Target_Object("DRESS");
Un_Combat_Target_Object("COATRACK");
Un_Combat_Target_Object("COLUMN3 DETS");

View File

@ -1507,8 +1507,9 @@ void ScriptBase::Clickable_Object(const char *objectName) {
void ScriptBase::Unclickable_Object(const char *objectName) {
debugC(kDebugScript, "Unclickable_Object(%s)", objectName);
int objectId = _vm->_scene->findObject(objectName);
if (objectId == -1)
if (objectId == -1) {
return;
}
_vm->_scene->objectSetIsClickable(objectId, false, !_vm->_sceneIsLoading);
}

View File

@ -90,7 +90,11 @@ bool Set::open(const Common::String &name) {
_objects[i].isTarget = 0;
s->skip(4);
}
#if BLADERUNNER_ORIGINAL_BUGS
#else
patchInAdditionalObjectsInSet();
patchOutBadObjectsFromSet();
#endif // BLADERUNNER_ORIGINAL_BUGS
_walkboxCount = s->readUint32LE();
assert(_walkboxCount <= 95);
@ -131,7 +135,10 @@ bool Set::open(const Common::String &name) {
void Set::addObjectsToScene(SceneObjects *sceneObjects) const {
for (int i = 0; i < _objectCount; i++) {
#if BLADERUNNER_ORIGINAL_BUGS
#else
overrideSceneObjectInfo(i); // For bugfixes with respect to clickable/targetable box positioning/bounding box
#endif // BLADERUNNER_ORIGINAL_BUGS
sceneObjects->addObject(i + kSceneObjectOffsetObjects, _objects[i].bbox, _objects[i].isClickable, _objects[i].isObstacle, _objects[i].unknown1, _objects[i].isTarget);
}
}
@ -420,6 +427,8 @@ void Set::load(SaveFileReadStream &f) {
_footstepSoundOverride = f.readInt();
}
#if BLADERUNNER_ORIGINAL_BUGS
#else
/**
* Used for bugfixes mainly with respect to bad box positioning / bounding box fixes
* TODO If we have many such cases, perhaps we could use a lookup table
@ -455,6 +464,13 @@ void Set::overrideSceneObjectInfo(int objectId) const {
_objects[objectId].bbox.setXYZ(695.63f, 42.65f, -628.10f, 706.71f, 69.22f, -614.47f);
}
break;
case kSceneNR11:
// Right coat rack needs adjustment of bounding box
if (objectId == 1 && _objects[objectId].name == "COATRACK") {
_objects[objectId].bbox.setXYZ(14.91f, 0.0f, -368.79f, 114.67f, 87.04f, -171.28f);
}
break;
case kSceneUG09:
// block passage to buggy pipe
if (objectId == 7 && _objects[objectId].name == "BOXS FOR ARCHWAY 01") {
@ -506,4 +522,40 @@ void Set::patchInAdditionalObjectsInSet() {
_objects[objectId].isTarget = 0; // init as false - Can be changed in Scene script eg. SceneLoaded() with (Un_)Combat_Target_Object
}
/**
* Used for "removing" objects from a Set mainly to fix a few "McCoy walking to places he should not" issues
* This is called in Set::open()
* Note:
* - ScummVM (post fix) save games will have the removed objects information
* - Original save games will not have the removed objects info if the save game room scene was an affected scene
* but they will get them if the player exits and re-enters. This should not be an issue.
*/
void Set::patchOutBadObjectsFromSet() {
int removedIndexRef = 0;
switch (_vm->_scene->getSceneId()) {
case kSceneNR11:
for (int objectId = 0; objectId < _objectCount; ++objectId) {
if ((objectId == 46 && _objects[objectId].name == "BOX53")
|| (objectId == 36 && _objects[objectId].name == "BOX43")
|| (objectId == 37 && _objects[objectId].name == "BOX44")
|| (objectId == 13 && _objects[objectId].name == "LOFT04")
) {
// Removing obj 46, 36, 37 (BOX53, BOX43, BOX44) fixes paths in the scene
// Removing obj 13 (LOFT04) fixes duplicate named box that confuses the engine
_objects[objectId].name = Common::String::format("REMOVED%02d", removedIndexRef++);
_objects[objectId].isObstacle = 0;
_objects[objectId].isClickable = 0;
_objects[objectId].isHotMouse = 0;
_objects[objectId].unknown1 = 0;
_objects[objectId].isTarget = 0;
}
}
break;
default:
break;
}
return;
}
#endif // BLADERUNNER_ORIGINAL_BUGS
} // End of namespace BladeRunner

View File

@ -107,8 +107,12 @@ public:
private:
static bool isXZInWalkbox(float x, float z, const Walkbox &walkbox);
#if BLADERUNNER_ORIGINAL_BUGS
#else
void overrideSceneObjectInfo(int objectId) const;
void patchInAdditionalObjectsInSet();
void patchOutBadObjectsFromSet();
#endif // BLADERUNNER_ORIGINAL_BUGS
};
} // End of namespace BladeRunner