[Scummvm-git-logs] scummvm master -> 8704207550e6506886e55e6b23868b14ffd4d8ca

peterkohaut peterkohaut at users.noreply.github.com
Mon Feb 19 22:18:29 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:
8704207550 BLADERUNNER: McCoy script fixed


Commit: 8704207550e6506886e55e6b23868b14ffd4d8ca
    https://github.com/scummvm/scummvm/commit/8704207550e6506886e55e6b23868b14ffd4d8ca
Author: Peter Kohaut (peter.kohaut at gmail.com)
Date: 2018-02-19T22:17:08+01:00

Commit Message:
BLADERUNNER: McCoy script fixed

Some Coverity issues fixed
KIA script small fix to DNA evidences
Actor selection fixed (bounding box is correcly expanded)

Changed paths:
    engines/bladerunner/actor.cpp
    engines/bladerunner/bladerunner.cpp
    engines/bladerunner/dialogue_menu.cpp
    engines/bladerunner/game_constants.h
    engines/bladerunner/scene_objects.cpp
    engines/bladerunner/scene_objects.h
    engines/bladerunner/script/ai/leon.cpp
    engines/bladerunner/script/ai/maggie.cpp
    engines/bladerunner/script/ai/mccoy.cpp
    engines/bladerunner/script/ai/officer_leary.cpp
    engines/bladerunner/script/ai/runciter.cpp
    engines/bladerunner/script/ai_script.h
    engines/bladerunner/script/kia_script.cpp
    engines/bladerunner/script/scene/ug05.cpp


diff --git a/engines/bladerunner/actor.cpp b/engines/bladerunner/actor.cpp
index c3f9372..50a96a4 100644
--- a/engines/bladerunner/actor.cpp
+++ b/engines/bladerunner/actor.cpp
@@ -249,18 +249,18 @@ void Actor::timerUpdate(int timerId) {
 void Actor::movementTrackNext(bool omitAiScript) {
 	bool hasNextMovement;
 	int waypointSetId;
-	bool run;
+	bool running;
 	int angle;
 	int delay;
 	int waypointId;
 	Vector3 waypointPosition;
 	bool arrived;
 
-	hasNextMovement = _movementTrack->next(&waypointId, &delay, &angle, &run);
+	hasNextMovement = _movementTrack->next(&waypointId, &delay, &angle, &running);
 	_movementTrackNextWaypointId = waypointId;
 	_movementTrackNextDelay = delay;
 	_movementTrackNextAngle = angle;
-	_movementTrackNextRunning = run;
+	_movementTrackNextRunning = running;
 	if (hasNextMovement) {
 		if (angle == -1) {
 			angle = 0;
@@ -269,7 +269,7 @@ void Actor::movementTrackNext(bool omitAiScript) {
 		_vm->_waypoints->getXYZ(waypointId, &waypointPosition.x, &waypointPosition.y, &waypointPosition.z);
 		if (_setId == waypointSetId && waypointSetId == _vm->_actors[0]->_setId) {
 			stopWalking(false);
-			_walkInfo->setup(_id, run, _position, waypointPosition, false, &arrived);
+			_walkInfo->setup(_id, running, _position, waypointPosition, false, &arrived);
 
 			_movementTrackWalkingToWaypointId = waypointId;
 			_movementTrackDelayOnNextWaypoint = delay;
@@ -966,22 +966,24 @@ void Actor::combatModeOn(int a2, int a3, int otherActorId, int a5, int animation
 	_animationModeCombatWalk = animationModeCombatWalk;
 	_animationModeCombatRun = animationModeCombatRun;
 	_inCombat = true;
-	if (_id != kActorMcCoy)
+	if (_id != kActorMcCoy) {
 		_combatInfo->combatOn(_id, a2, a3, otherActorId, a5, a9, a10, a11, ammoDamage, a13, a14);
+	}
 	stopWalking(false);
 	changeAnimationMode(_animationModeCombatIdle, false);
 	int i;
 	for (i = 0; i < (int)_vm->_gameInfo->getActorCount(); i++) {
 		Actor *otherActor = _vm->_actors[i];
 		if (i != _id && otherActor->_setId == _setId && !otherActor->_isRetired) {
-			//TODO: _vm->actorScript->OtherAgentEnteredCombatMode(i, _id, 1);
+			_vm->_aiScripts->otherAgentEnteredCombatMode(i, _id, true);
 		}
 	}
 }
 
 void Actor::combatModeOff() {
-	if (_id > 0)
+	if (_id != kActorMcCoy) {
 		_combatInfo->combatOff();
+	}
 	_inCombat = false;
 	stopWalking(false);
 	changeAnimationMode(kAnimationModeIdle, false);
@@ -989,7 +991,7 @@ void Actor::combatModeOff() {
 	for (i = 0; i < (int)_vm->_gameInfo->getActorCount(); i++) {
 		Actor *otherActor = _vm->_actors[i];
 		if (i != _id && otherActor->_setId == _setId && !otherActor->_isRetired) {
-			//TODO: _vm->actorScript->OtherAgentEnteredCombatMode(i, _id, 0);
+			_vm->_aiScripts->otherAgentEnteredCombatMode(i, _id, false);
 		}
 	}
 }
diff --git a/engines/bladerunner/bladerunner.cpp b/engines/bladerunner/bladerunner.cpp
index 2bb8e01..7a24f8d 100644
--- a/engines/bladerunner/bladerunner.cpp
+++ b/engines/bladerunner/bladerunner.cpp
@@ -839,6 +839,9 @@ void BladeRunnerEngine::gameTick() {
 				_dialogueMenu->draw(_surfaceFront);
 			}
 
+			// TODO: remove zbuffer draw
+			// _surfaceFront.copyRectToSurface(_zbuffer->getData(), 1280, 0, 0, 640, 480);
+
 			_mouse->tick(p.x, p.y);
 			_mouse->draw(_surfaceFront, p.x, p.y);
 
@@ -857,7 +860,7 @@ void BladeRunnerEngine::gameTick() {
 				for (int i = 0; i < count; i++) {
 					SceneObjects::SceneObject *sceneObject = &_sceneObjects->_sceneObjects[_sceneObjects->_sceneObjectsSortedByDistance[i]];
 
-					BoundingBox *bbox = &sceneObject->boundingBox;
+					const BoundingBox *bbox = sceneObject->boundingBox;
 					Vector3 a, b;
 					bbox->getXYZ(&a.x, &a.y, &a.z, &b.x, &b.y, &b.z);
 					Vector3 pos = _view->calculateScreenPosition(0.5 * (a + b));
@@ -1410,7 +1413,7 @@ void BladeRunnerEngine::handleMouseClickEmpty(int x, int y, Vector3 &scenePositi
 	int actorId = Actor::findTargetUnderMouse(this, x, y);
 	int itemId = _items->findTargetUnderMouse(x, y);
 
-	if (_combat->isActive() && buttonDown && actorId > 0 && itemId > 0) {
+	if (_combat->isActive() && buttonDown && (actorId > 0 || itemId > 0)) {
 		_playerActor->stopWalking(false);
 		if (actorId > 0) {
 			_playerActor->faceActor(actorId, false);
diff --git a/engines/bladerunner/dialogue_menu.cpp b/engines/bladerunner/dialogue_menu.cpp
index 6f7ff38..f5a63e0 100644
--- a/engines/bladerunner/dialogue_menu.cpp
+++ b/engines/bladerunner/dialogue_menu.cpp
@@ -224,9 +224,7 @@ int DialogueMenu::queryInput() {
 		}
 	}
 
-	if (_selectedItemIndex >= 0) {
-		debug("DM Query Input: %d %s", answer, _items[_selectedItemIndex].text.c_str());
-	}
+	debug("DM Query Input: %d %s", answer, _items[_selectedItemIndex].text.c_str());
 
 	return answer;
 }
diff --git a/engines/bladerunner/game_constants.h b/engines/bladerunner/game_constants.h
index 54f5fed..032c40c 100644
--- a/engines/bladerunner/game_constants.h
+++ b/engines/bladerunner/game_constants.h
@@ -506,6 +506,7 @@ enum Variables {
 	kVariableWalkLoopActor = 37,
 	kVariableWalkLoopRun = 38,
 	kVariableAffectionTowards = 45, // 0 none, 1 steele, 2 dektora, 3 lucy
+	kVariableDNAEvidences = 48,
 	kVariableNextTvNews = 52
 };
 
diff --git a/engines/bladerunner/scene_objects.cpp b/engines/bladerunner/scene_objects.cpp
index 5d22be4..79c3e0b 100644
--- a/engines/bladerunner/scene_objects.cpp
+++ b/engines/bladerunner/scene_objects.cpp
@@ -108,9 +108,9 @@ int SceneObjects::findByXYZ(bool *isClickable, bool *isObstacle, bool *isTarget,
 		if ((findClickables && sceneObject->isClickable) ||
 			(findObstacles  && sceneObject->isObstacle) ||
 			(findTargets    && sceneObject->isTarget)) {
-			BoundingBox boundingBox = sceneObject->boundingBox;
+			BoundingBox boundingBox = *sceneObject->boundingBox;
 
-			if (sceneObject->type == kSceneObjectTypeObject || sceneObject->type == kSceneObjectTypeItem) {
+			if (sceneObject->type == kSceneObjectTypeActor) {
 				boundingBox.expand(-4.0, 0.0, -4.0, 4.0, 0.0, 4.0);
 			}
 
@@ -153,7 +153,7 @@ bool SceneObjects::existsOnXZ(int exceptSceneObjectId, float x, float z, bool mo
 
 			if (isObstacle && sceneObject->id != exceptSceneObjectId) {
 				float x1, y1, z1, x2, y2, z2;
-				sceneObject->boundingBox.getXYZ(&x1, &y1, &z1, &x2, &y2, &z2);
+				sceneObject->boundingBox->getXYZ(&x1, &y1, &z1, &x2, &y2, &z2);
 				if (z1 <= zMax && z2 >= zMin && x1 <= xMax && x2 >= xMin) {
 					return true;
 				}
@@ -183,7 +183,7 @@ bool SceneObjects::addSceneObject(int sceneObjectId, SceneObjectType sceneObject
 	_sceneObjects[index].id              = sceneObjectId;
 	_sceneObjects[index].type            = sceneObjectType;
 	_sceneObjects[index].isPresent       = true;
-	_sceneObjects[index].boundingBox     = *boundingBox;
+	_sceneObjects[index].boundingBox     = boundingBox;
 	_sceneObjects[index].screenRectangle = screenRectangle;
 	_sceneObjects[index].isClickable     = isClickable;
 	_sceneObjects[index].isObstacle      = isObstacle;
@@ -192,7 +192,7 @@ bool SceneObjects::addSceneObject(int sceneObjectId, SceneObjectType sceneObject
 	_sceneObjects[index].isMoving        = isMoving;
 	_sceneObjects[index].isRetired       = isRetired;
 
-	float centerZ = (_sceneObjects[index].boundingBox.getZ0() + _sceneObjects[index].boundingBox.getZ1()) / 2.0;
+	float centerZ = (_sceneObjects[index].boundingBox->getZ0() + _sceneObjects[index].boundingBox->getZ1()) / 2.0;
 
 	float distanceToCamera = fabs(_view->_cameraPosition.z - centerZ);
 	_sceneObjects[index].distanceToCamera = distanceToCamera;
@@ -244,7 +244,7 @@ bool SceneObjects::isBetween(float sourceX, float sourceZ, float targetX, float
 	}
 
 	float objectX1, objectY1, objectZ1, objectX2, objectY2, objectZ2;
-	_sceneObjects[i].boundingBox.getXYZ(&objectX1, &objectY1, &objectZ1, &objectX2, &objectY2, &objectZ2);
+	_sceneObjects[i].boundingBox->getXYZ(&objectX1, &objectY1, &objectZ1, &objectX2, &objectY2, &objectZ2);
 
 	Vector2 intersection;
 	return lineIntersection(Vector2(sourceX, sourceZ), Vector2(targetX, targetZ), Vector2(objectX1, objectZ1), Vector2(objectX2, objectZ1), &intersection)
@@ -262,7 +262,7 @@ bool SceneObjects::isObstacleBetween(float sourceX, float sourceZ, float targetX
 		}
 
 		float objectX1, objectY1, objectZ1, objectX2, objectY2, objectZ2;
-		_sceneObjects[i].boundingBox.getXYZ(&objectX1, &objectY1, &objectZ1, &objectX2, &objectY2, &objectZ2);
+		_sceneObjects[i].boundingBox->getXYZ(&objectX1, &objectY1, &objectZ1, &objectX2, &objectY2, &objectZ2);
 
 		if (84.0f <= objectY1 - altitude || 72.0f >= objectY2 - altitude) {
 			continue;
@@ -318,7 +318,7 @@ void SceneObjects::updateObstacles() {
 		const SceneObject *sceneObject = &_sceneObjects[index];
 		if (sceneObject->isObstacle) {
 			float x0, y0, z0, x1, y1, z1;
-			sceneObject->boundingBox.getXYZ(&x0, &y0, &z0, &x1, &y1, &z1);
+			sceneObject->boundingBox->getXYZ(&x0, &y0, &z0, &x1, &y1, &z1);
 			_vm->_obstacles->add(x0, z0, x1, z1);
 		}
 	}
diff --git a/engines/bladerunner/scene_objects.h b/engines/bladerunner/scene_objects.h
index 624deee..f0a78da 100644
--- a/engines/bladerunner/scene_objects.h
+++ b/engines/bladerunner/scene_objects.h
@@ -46,18 +46,18 @@ class SceneObjects {
 	static const int kSceneObjectCount = 115;
 
 	struct SceneObject {
-		int             id;
-		SceneObjectType type;
-		BoundingBox     boundingBox;
-		Common::Rect   *screenRectangle;
-		float           distanceToCamera;
-		bool            isPresent;
-		bool            isClickable;
-		bool            isObstacle;
-		int             unknown1;
-		bool            isTarget;
-		bool            isMoving;
-		bool            isRetired;
+		int                 id;
+		SceneObjectType     type;
+		const BoundingBox  *boundingBox;
+		const Common::Rect *screenRectangle;
+		float               distanceToCamera;
+		bool                isPresent;
+		bool                isClickable;
+		bool                isObstacle;
+		int                 unknown1;
+		bool                isTarget;
+		bool                isMoving;
+		bool                isRetired;
 	};
 
 	BladeRunnerEngine *_vm;
diff --git a/engines/bladerunner/script/ai/leon.cpp b/engines/bladerunner/script/ai/leon.cpp
index 3d136ee..bc06b0d 100644
--- a/engines/bladerunner/script/ai/leon.cpp
+++ b/engines/bladerunner/script/ai/leon.cpp
@@ -24,6 +24,13 @@
 
 namespace BladeRunner {
 
+AIScriptLeon::AIScriptLeon(BladeRunnerEngine *vm) : AIScriptBase(vm) {
+	var_45EDA0_z = 0.0f;
+	var_45EDA4_y = 0.0f;
+	var_45EDA8_x = 0.0f;
+	var_45EDAC = 0;
+}
+
 void AIScriptLeon::Initialize() {
 	var_45EDA0_z = 0.0f;
 	var_45EDA4_y = 0.0f;
diff --git a/engines/bladerunner/script/ai/maggie.cpp b/engines/bladerunner/script/ai/maggie.cpp
index 89dd651..09631d4 100644
--- a/engines/bladerunner/script/ai/maggie.cpp
+++ b/engines/bladerunner/script/ai/maggie.cpp
@@ -45,6 +45,14 @@ enum kMaggieStates {
 	kMaggieStateDead         = 16
 };
 
+AIScriptMaggie::AIScriptMaggie(BladeRunnerEngine *vm) : AIScriptBase(vm) {
+	var_45F3F8 = 0;
+	var_45F3FC = 0;
+	var_45F400 = 0;
+	var_45F404 = 0;
+	var_45F408 = 0;
+}
+
 void AIScriptMaggie::Initialize() {
 	_animationState = kMaggieStateIdle;
 	_animationFrame = 0;
diff --git a/engines/bladerunner/script/ai/mccoy.cpp b/engines/bladerunner/script/ai/mccoy.cpp
index 3f3888f..b38e328 100644
--- a/engines/bladerunner/script/ai/mccoy.cpp
+++ b/engines/bladerunner/script/ai/mccoy.cpp
@@ -24,12 +24,28 @@
 
 namespace BladeRunner {
 
+AIScriptMcCoy::AIScriptMcCoy(BladeRunnerEngine *vm) : AIScriptBase(vm) {
+	dword_45A0D8 = 0;
+	dword_45A0DC = 0;
+	_animationFrameDelta = 0;
+	dword_45A0E4 = 0;
+	off_45A0EC = 0.0f;
+	dword_45A0E8 = 0;
+	dword_45A0F0 = 0;
+	dword_45A0F4 = 0;
+	dword_45A0F8 = 0;
+	dword_45A0FC = 0;
+	off_45A100 = 0.0f;
+	flt_462710 = 0.0f;
+	flt_462714 = 0.0f;
+}
+
 void AIScriptMcCoy::Initialize() {
 	_animationState = 0;
 	_animationFrame = 0;
 	dword_45A0D8 = 0;
 	dword_45A0DC = 30;
-	dword_45A0E0 = 1;
+	_animationFrameDelta = 1;
 	dword_45A0E4 = 0;
 	off_45A0EC = 0;
 	dword_45A0E8 = 3;
@@ -61,11 +77,11 @@ bool AIScriptMcCoy::Update() {
 		return true;
 	case 201:
 		Actor_Set_Goal_Number(kActorMcCoy, 0);
-		if (Player_Query_Current_Set() == 55) {
-			Loop_Actor_Walk_To_XYZ(kActorMcCoy, -166.0f, -70.19f, -501.0f, 0, 0, false, 0);
+		if (Player_Query_Current_Set() == kSetNR03) {
+			Loop_Actor_Walk_To_XYZ(kActorMcCoy, -166.0f, -70.19f, -501.0f, 0, false, false, 0);
 			Actor_Face_Heading(kActorMcCoy, 300, false);
 		} else {
-			Loop_Actor_Walk_To_XYZ(kActorMcCoy, -461.0f, 0.0f, -373.0f, 0, 0, false, 0);
+			Loop_Actor_Walk_To_XYZ(kActorMcCoy, -461.0f, 0.0f, -373.0f, 0, false, false, 0);
 		}
 		Player_Gains_Control();
 		return true;
@@ -102,84 +118,84 @@ void AIScriptMcCoy::CompletedMovementTrack() {
 
 void AIScriptMcCoy::ReceivedClue(int clueId, int fromActorId) {
 	switch (clueId) {
-	case 8:
-	case 9:
-		Spinner_Set_Selectable_Destination_Flag(3, 1);
+	case kClueChopstickWrapper:
+	case kClueSushiMenu:
+		Spinner_Set_Selectable_Destination_Flag(kSpinnerDestinationChinatown, true);
 		break;
-	case 44:
-	case 47:
-		Spinner_Set_Selectable_Destination_Flag(4, 1);
+	case kClueDragonflyEarring:
+	case kClueBombingSuspect:
+		Spinner_Set_Selectable_Destination_Flag(kSpinnerDestinationAnimoidRow, true);
 		break;
-	case 53:
-	case 263:
+	case kClueKingstonKitchenBox1:
+	case kClueKingstonKitchenBox2:
 		if (Query_Difficulty_Level() == 0) {
-			Spinner_Set_Selectable_Destination_Flag(4, 1);
+			Spinner_Set_Selectable_Destination_Flag(kSpinnerDestinationAnimoidRow, true);
 		}
 		break;
-	case 90:
-		Spinner_Set_Selectable_Destination_Flag(8, 1);
+	case kClueDragonflyCollection:
+		Spinner_Set_Selectable_Destination_Flag(kSpinnerDestinationNightclubRow, true);
 		break;
-	case 84:
-	case 113:
-	case 114:
-	case 115:
-	case 118:
-		Spinner_Set_Selectable_Destination_Flag(9, 1);
-		Spinner_Set_Selectable_Destination_Flag(8, 1);
+	case kClueHysteriaToken:
+	case kClueCarRegistration1:
+	case kClueCarRegistration2:
+	case kClueCarRegistration3:
+	case kClueLichenDogWrapper:
+		Spinner_Set_Selectable_Destination_Flag(kSpinnerDestinationHysteriaHall, true);
+		Spinner_Set_Selectable_Destination_Flag(kSpinnerDestinationNightclubRow, true);
 		break;
-	case 66:
-	case 80:
-	case 82:
-	case 83:
+	case kClueWeaponsCache:
+	case kClueWeaponsOrderForm:
+	case kClueShippingForm:
+	case kCluePoliceIssueWeapons:
 		Global_Variable_Increment(49, 1);
 		break;
-	case 125:
+	case kClueFolder:
 		Global_Variable_Increment(49, 5);
 		break;
-	case 124:
-	case 128:
+	case kClueHomelessManKid:
+	case kClueOriginalRequisitionForm:
 		Global_Variable_Increment(49, 3);
 		break;
-	case 120:
-	case 121:
+	case kClueScaryChair:
+	case kClueIzosStashRaided:
 		Global_Variable_Increment(49, 2);
 		break;
-	case 147:
-	case 148:
-	case 149:
-	case 150:
-	case 151:
-	case 152:
-		Global_Variable_Increment(48, 1);
+	case kClueDNATyrell:
+	case kClueDNASebastian:
+	case kClueDNAChew:
+	case kClueDNAMoraji:
+	case kClueDNALutherLance:
+	case kClueDNAMarcus:
+		Global_Variable_Increment(kVariableDNAEvidences, 1);
 		break;
 	}
 	if (Global_Variable_Query(49) > 6 && Global_Variable_Query(kVariableChapter) > 3 && !Actor_Clue_Query(kActorMcCoy, kClueGuzzaFramedMcCoy)) {
 		Delay(500);
 		Actor_Voice_Over(3320, kActorVoiceOver);
 		switch (clueId) {
-		case 66:
-		case 80:
-		case 82:
-		case 83:
-		case 121:
-		case 128:
+		case kClueWeaponsCache:
+		case kClueWeaponsOrderForm:
+		case kClueGuzzasCash:
+		case kCluePoliceIssueWeapons:
+		case kClueIzosStashRaided:
+		case kClueOriginalRequisitionForm:
 			Actor_Voice_Over(3340, kActorVoiceOver);
 			Actor_Voice_Over(3350, kActorVoiceOver);
 			Actor_Voice_Over(3360, kActorVoiceOver);
 			Actor_Voice_Over(3370, kActorVoiceOver);
 			Actor_Voice_Over(3380, kActorVoiceOver);
 			break;
-		case 124:
+		case kClueHomelessManKid:
 			Actor_Voice_Over(3330, kActorVoiceOver);
 			break;
-		case 120:
+		case kClueScaryChair:
 			Actor_Voice_Over(3390, kActorVoiceOver);
 			Actor_Voice_Over(3400, kActorVoiceOver);
 			Actor_Voice_Over(3420, kActorVoiceOver);
 			break;
 		}
 		Actor_Clue_Acquire(kActorMcCoy, kClueGuzzaFramedMcCoy, 1, -1);
-		if (clueId == 125) {
+		if (clueId == kClueFolder) {
 			Actor_Voice_Over(2780, kActorVoiceOver);
 			Actor_Voice_Over(2800, kActorVoiceOver);
 			Actor_Voice_Over(2810, kActorVoiceOver);
@@ -224,23 +240,23 @@ bool AIScriptMcCoy::ShotAtAndHit() {
 }
 
 void AIScriptMcCoy::Retired(int byActorId) {
-	if (byActorId == kActorSteele && Actor_Query_In_Set(kActorSteele, 42)) {
-		if (Actor_Query_In_Set(kActorDektora, 42) && Actor_Query_Goal_Number(kActorDektora) != 599) {
+	if (byActorId == kActorSteele && Actor_Query_In_Set(kActorSteele, kSetHF06)) {
+		if (Actor_Query_In_Set(kActorDektora, kSetHF06) && Actor_Query_Goal_Number(kActorDektora) != 599) {
 			Non_Player_Actor_Combat_Mode_On(kActorSteele, 3, 1, kActorDektora, 15, 4, 7, 8, 0, 0, 100, 25, 300, 0);
-		} else if (Actor_Query_In_Set(kActorLucy, 42) && Actor_Query_Goal_Number(kActorLucy) != 599) {
+		} else if (Actor_Query_In_Set(kActorLucy, kSetHF06) && Actor_Query_Goal_Number(kActorLucy) != 599) {
 			Non_Player_Actor_Combat_Mode_On(kActorSteele, 3, 1, kActorLucy, 15, 4, 7, 8, 0, 0, 100, 25, 300, 0);
 		}
 	}
-	if (Actor_Query_In_Set(kActorMcCoy, 41) && Actor_Query_In_Set(kActorOfficerLeary, 41) && Actor_Query_In_Set(kActorDektora, 41) && Actor_Query_Goal_Number(kActorDektora) != 599) {
+	if (Actor_Query_In_Set(kActorMcCoy, kSetHF05) && Actor_Query_In_Set(kActorOfficerLeary, kSetHF05) && Actor_Query_In_Set(kActorDektora, kSetHF05) && Actor_Query_Goal_Number(kActorDektora) != 599) {
 		Non_Player_Actor_Combat_Mode_On(kActorOfficerLeary, 3, 1, kActorDektora, 4, 4, 7, 8, 0, 0, 100, 25, 300, 0);
 	}
-	if (Actor_Query_In_Set(kActorMcCoy, 41) && Actor_Query_In_Set(kActorOfficerGrayford, 41) && Actor_Query_In_Set(kActorDektora, 41) && Actor_Query_Goal_Number(kActorDektora) != 599) {
+	if (Actor_Query_In_Set(kActorMcCoy, kSetHF05) && Actor_Query_In_Set(kActorOfficerGrayford, kSetHF05) && Actor_Query_In_Set(kActorDektora, kSetHF05) && Actor_Query_Goal_Number(kActorDektora) != 599) {
 		Non_Player_Actor_Combat_Mode_On(kActorOfficerGrayford, 3, 1, kActorDektora, 4, 4, 7, 8, 0, 0, 100, 25, 300, 0);
 	}
-	if (Actor_Query_In_Set(kActorMcCoy, 41) && Actor_Query_In_Set(kActorOfficerLeary, 41) && Actor_Query_In_Set(kActorLucy, 41) && Actor_Query_Goal_Number(kActorLucy) != 599) {
+	if (Actor_Query_In_Set(kActorMcCoy, kSetHF05) && Actor_Query_In_Set(kActorOfficerLeary, kSetHF05) && Actor_Query_In_Set(kActorLucy, kSetHF05) && Actor_Query_Goal_Number(kActorLucy) != 599) {
 		Non_Player_Actor_Combat_Mode_On(kActorOfficerLeary, 3, 1, kActorLucy, 4, 4, 7, 8, 0, 0, 100, 25, 300, 0);
 	}
-	if (Actor_Query_In_Set(kActorMcCoy, 41) && Actor_Query_In_Set(kActorOfficerGrayford, 41) && Actor_Query_In_Set(kActorLucy, 41) && Actor_Query_Goal_Number(kActorLucy) != 599) {
+	if (Actor_Query_In_Set(kActorMcCoy, kSetHF05) && Actor_Query_In_Set(kActorOfficerGrayford, kSetHF05) && Actor_Query_In_Set(kActorLucy, kSetHF05) && Actor_Query_Goal_Number(kActorLucy) != 599) {
 		Non_Player_Actor_Combat_Mode_On(kActorOfficerGrayford, 3, 1, kActorLucy, 4, 4, 7, 8, 0, 0, 100, 25, 300, 0);
 	}
 }
@@ -269,7 +285,7 @@ bool AIScriptMcCoy::GoalChanged(int currentGoalNumber, int newGoalNumber) {
 		Actor_Set_Invisible(kActorMcCoy, false);
 		return true;
 	case 102:
-		Async_Actor_Walk_To_Waypoint(kActorMcCoy, 316, 0, 1);
+		Async_Actor_Walk_To_Waypoint(kActorMcCoy, 316, 0, true);
 		return true;
 	case 103:
 		Actor_Face_Actor(kActorMcCoy, kActorSadik, true);
@@ -277,10 +293,10 @@ bool AIScriptMcCoy::GoalChanged(int currentGoalNumber, int newGoalNumber) {
 	case 231:
 		Player_Set_Combat_Mode(false);
 		Preload(18);
-		Set_Enter(59, kSceneNR10);
+		Set_Enter(kSetNR10, kSceneNR10);
 		Player_Loses_Control();
 		Actor_Force_Stop_Walking(kActorMcCoy);
-		Actor_Put_In_Set(kActorMcCoy, 59);
+		Actor_Put_In_Set(kActorMcCoy, kSetNR10);
 		Actor_Set_At_XYZ(kActorMcCoy, 14.0f, 110.84f, -300.0f, 926);
 		Actor_Change_Animation_Mode(kActorMcCoy, 48);
 		_animationState = 27;
@@ -291,7 +307,7 @@ bool AIScriptMcCoy::GoalChanged(int currentGoalNumber, int newGoalNumber) {
 		return true;
 	case 230:
 		dword_45A0FC = Actor_Query_Goal_Number(kActorSteele) == 215;
-		Actor_Change_Animation_Mode(kActorMcCoy, 6);
+		Actor_Change_Animation_Mode(kActorMcCoy, kAnimationModeCombatShoot);
 		return true;
 	case 220:
 		Actor_Change_Animation_Mode(kActorMcCoy, 75);
@@ -313,12 +329,12 @@ bool AIScriptMcCoy::GoalChanged(int currentGoalNumber, int newGoalNumber) {
 			Actor_Change_Animation_Mode(kActorMcCoy, 16);
 		}
 		Delay(150);
-		Actor_Change_Animation_Mode(kActorMcCoy, 0);
+		Actor_Change_Animation_Mode(kActorMcCoy, kAnimationModeIdle);
 		Actor_Set_Goal_Number(kActorMcCoy, 0);
 		Player_Gains_Control();
 		return true;
 	case 210:
-		Actor_Put_In_Set(kActorMcCoy, 54);
+		Actor_Put_In_Set(kActorMcCoy, kSetNR01);
 		Actor_Set_At_XYZ(kActorMcCoy, -204.0, 24.0, -817.0, 256);
 		Actor_Set_Invisible(kActorMcCoy, false);
 		if (Game_Flag_Query(627)) {
@@ -331,7 +347,7 @@ bool AIScriptMcCoy::GoalChanged(int currentGoalNumber, int newGoalNumber) {
 		return true;
 	case 200:
 		Player_Loses_Control();
-		Actor_Change_Animation_Mode(kActorMcCoy, 0);
+		Actor_Change_Animation_Mode(kActorMcCoy, kAnimationModeIdle);
 		return true;
 	case 301:
 		_animationState = 62;
@@ -427,23 +443,23 @@ bool AIScriptMcCoy::GoalChanged(int currentGoalNumber, int newGoalNumber) {
 		}
 		Ambient_Sounds_Remove_All_Non_Looping_Sounds(1);
 		Ambient_Sounds_Remove_All_Looping_Sounds(1);
-		Global_Variable_Set(1, 5);
+		Global_Variable_Set(kVariableChapter, 5);
 		Outtake_Play(kOuttakeMovieD, false, -1);
 		if (Game_Flag_Query(666)) {
-			Chapter_Enter(5, 53, 53);
+			Chapter_Enter(5, kSetMA07, kSceneMA07);
 		} else {
 			Game_Flag_Set(kFlagMA06ToMA02);
-			Chapter_Enter(5, 10, 49);
+			Chapter_Enter(5, kSetMA02_MA04, kSceneMA02);
 		}
 		return true;
 	case 500:
 		Music_Stop(3);
 		Player_Set_Combat_Mode(false);
-		Actor_Change_Animation_Mode(kActorMcCoy, 0);
+		Actor_Change_Animation_Mode(kActorMcCoy, kAnimationModeIdle);
 		_animationState = 0;
 		_animationFrame = 0;
 		Game_Flag_Set(465);
-		Set_Enter(67, kScenePS09);
+		Set_Enter(kSetPS09, kScenePS09);
 		return true;
 	}
 	return false;
@@ -456,7 +472,7 @@ bool AIScriptMcCoy::UpdateAnimation(int *animation, int *frame) {
 		*animation = 52;
 		_animationFrame++;
 		if (_animationFrame >= Slice_Animation_Query_Number_Of_Frames(52)) {
-			Actor_Change_Animation_Mode(kActorMcCoy, 0);
+			Actor_Change_Animation_Mode(kActorMcCoy, kAnimationModeIdle);
 			*animation = 19;
 			_animationFrame = 0;
 			_animationState = 0;
@@ -487,7 +503,7 @@ bool AIScriptMcCoy::UpdateAnimation(int *animation, int *frame) {
 			_animationFrame--;
 		}
 		if (_animationFrame <= 0) {
-			Actor_Change_Animation_Mode(kActorMcCoy, 0);
+			Actor_Change_Animation_Mode(kActorMcCoy, kAnimationModeIdle);
 			*animation = 19;
 			_animationState = 0;
 			_animationFrame = 0;
@@ -501,7 +517,7 @@ bool AIScriptMcCoy::UpdateAnimation(int *animation, int *frame) {
 		*animation = 53;
 		_animationFrame++;
 		if (_animationFrame >= Slice_Animation_Query_Number_Of_Frames(53)) {
-			Actor_Change_Animation_Mode(kActorMcCoy, 0);
+			Actor_Change_Animation_Mode(kActorMcCoy, kAnimationModeIdle);
 			*animation = 19;
 			_animationState = 0;
 			_animationFrame = 0;
@@ -514,7 +530,7 @@ bool AIScriptMcCoy::UpdateAnimation(int *animation, int *frame) {
 		*animation = 40;
 		_animationFrame++;
 		if (_animationFrame >= Slice_Animation_Query_Number_Of_Frames(40)) {
-			Actor_Change_Animation_Mode(kActorMcCoy, 0);
+			Actor_Change_Animation_Mode(kActorMcCoy, kAnimationModeIdle);
 			*animation = 19;
 			_animationFrame = 0;
 			_animationState = 0;
@@ -600,7 +616,7 @@ bool AIScriptMcCoy::UpdateAnimation(int *animation, int *frame) {
 			}
 			Ambient_Sounds_Play_Sound(v19, 39, 0, 0, 99);
 		}
-		if (_animationFrame >= Slice_Animation_Query_Number_Of_Frames(*animation) - 1) { //why -1? 
+		if (_animationFrame >= Slice_Animation_Query_Number_Of_Frames(*animation) - 1) { //why -1?
 			_animationFrame = 0;
 		}
 		break;
@@ -621,12 +637,12 @@ bool AIScriptMcCoy::UpdateAnimation(int *animation, int *frame) {
 		_animationFrame++;
 		if (_animationFrame >= Slice_Animation_Query_Number_Of_Frames(49)) {
 			_animationFrame = 0;
-			if (Actor_Query_Which_Set_In(kActorMcCoy) == 87) {
+			if (Actor_Query_Which_Set_In(kActorMcCoy) == kSetUG15) {
 				_animationState = 27;
 			} else {
 				*animation = 19;
 				_animationState = 0;
-				Actor_Change_Animation_Mode(kActorMcCoy, 0);
+				Actor_Change_Animation_Mode(kActorMcCoy, kAnimationModeIdle);
 			}
 		}
 		break;
@@ -645,7 +661,7 @@ bool AIScriptMcCoy::UpdateAnimation(int *animation, int *frame) {
 		*animation = 18;
 		_animationFrame--;
 		if (_animationFrame <= 0) {
-			Actor_Change_Animation_Mode(kActorMcCoy, 0);
+			Actor_Change_Animation_Mode(kActorMcCoy, kAnimationModeIdle);
 			*animation = 19;
 			_animationFrame = 0;
 			_animationState = 0;
@@ -745,7 +761,7 @@ bool AIScriptMcCoy::UpdateAnimation(int *animation, int *frame) {
 	case 43:
 		*animation = 38;
 		_animationFrame++;
-		if (_animationFrame >= Slice_Animation_Query_Number_Of_Frames(38) - 1) { //why -1? 
+		if (_animationFrame >= Slice_Animation_Query_Number_Of_Frames(38) - 1) { //why -1?
 			_animationFrame = 0;
 		}
 		switch (_animationFrame) {
@@ -763,7 +779,7 @@ bool AIScriptMcCoy::UpdateAnimation(int *animation, int *frame) {
 	case 42:
 		*animation = 37;
 		_animationFrame++;
-		if (_animationFrame >= Slice_Animation_Query_Number_Of_Frames(37) - 1) { //why -1? 
+		if (_animationFrame >= Slice_Animation_Query_Number_Of_Frames(37) - 1) { //why -1?
 			_animationFrame = 0;
 		}
 		switch (_animationFrame) {
@@ -898,11 +914,11 @@ bool AIScriptMcCoy::UpdateAnimation(int *animation, int *frame) {
 		}
 		break;
 	case 29:
-		v46 = _animationFrame + dword_45A0E0;
+		v46 = _animationFrame + _animationFrameDelta;
 		*animation = 18;
 		_animationFrame = v46;
 		if (v46 < 14) {
-			dword_45A0E0 = 1;
+			_animationFrameDelta = 1;
 		}
 		if (_animationFrame >= Slice_Animation_Query_Number_Of_Frames(*animation)) {
 			Actor_Change_Animation_Mode(kActorMcCoy, 48);
@@ -939,7 +955,7 @@ bool AIScriptMcCoy::UpdateAnimation(int *animation, int *frame) {
 			*animation = 19;
 			_animationFrame = 0;
 			_animationState = 0;
-			Actor_Change_Animation_Mode(kActorMcCoy, 0);
+			Actor_Change_Animation_Mode(kActorMcCoy, kAnimationModeIdle);
 		}
 		break;
 	case 25:
@@ -949,7 +965,7 @@ bool AIScriptMcCoy::UpdateAnimation(int *animation, int *frame) {
 			*animation = 19;
 			_animationFrame = 0;
 			_animationState = 0;
-			Actor_Change_Animation_Mode(kActorMcCoy, 0);
+			Actor_Change_Animation_Mode(kActorMcCoy, kAnimationModeIdle);
 		}
 		break;
 	case 24:
@@ -1163,20 +1179,20 @@ bool AIScriptMcCoy::UpdateAnimation(int *animation, int *frame) {
 		*animation = 19;
 		if (dword_45A0D8 < dword_45A0DC) {
 			//*frame = dword_45A0E8;
-			_animationFrame += dword_45A0E0;
+			_animationFrame += _animationFrameDelta;
 			if (_animationFrame > dword_45A0E8) {
 				_animationFrame = dword_45A0E8;
-				dword_45A0E0 = -1;
+				_animationFrameDelta = -1;
 			} else if (_animationFrame < dword_45A0E4) {
 				_animationFrame = dword_45A0E4;
-				dword_45A0E0 = 1;
+				_animationFrameDelta = 1;
 			}
 			dword_45A0D8++;
 		} else {
-			_animationFrame += dword_45A0E0;
+			_animationFrame += _animationFrameDelta;
 			dword_45A0DC = 0;
 			if (_animationFrame == 18 && Random_Query(0, 2)) {
-				dword_45A0E0 = -1;
+				_animationFrameDelta = -1;
 				dword_45A0D8 = 0;
 				dword_45A0E4 = 14;
 				dword_45A0E8 = 18;
@@ -1184,7 +1200,7 @@ bool AIScriptMcCoy::UpdateAnimation(int *animation, int *frame) {
 			}
 			if (_animationFrame == 26) {
 				if (Random_Query(0, 2)) {
-					dword_45A0E0 = -1;
+					_animationFrameDelta = -1;
 					dword_45A0D8 = 0;
 					dword_45A0E4 = 23;
 					dword_45A0E8 = 26;
@@ -1211,226 +1227,224 @@ bool AIScriptMcCoy::UpdateAnimation(int *animation, int *frame) {
 }
 
 bool AIScriptMcCoy::ChangeAnimationMode(int mode) {
-	int v2;
 	switch (mode) {
-	case 85:
-		_animationFrame = 0;
-		_animationState = 69;
-		return true;
-	case 75:
-		_animationState = 67;
-		_animationFrame = 0;
-		return true;
-	case 68:
-		_animationState = 29;
-		_animationFrame = Slice_Animation_Query_Number_Of_Frames(18) - 1;
-		dword_45A0E0 = -1;
-		return true;
-	case 65:
-	case 67:
-		_animationState = 43;
-		_animationFrame = 0;
-		return true;
-	case 64:
-	case 66:
-		_animationState = 42;
-		_animationFrame = 0;
-		return true;
-	case 53:
-		if (_animationState != 60 && (Player_Query_Current_Set() == 55 || Player_Query_Current_Set() == 13)) {
-			_animationState = 60;
-			_animationFrame = 0;
+	case kAnimationModeIdle:
+		if (!Game_Flag_Query(550)) {
+			switch (_animationState) {
+			case 3:
+			case 4:
+			case 5:
+			case 6:
+			case 7:
+			case 8:
+			case 9:
+			case 10:
+			case 11:
+			case 12:
+				Game_Flag_Set(236);
+				dword_45A0D8 = 0;
+				dword_45A0DC = 30;
+				dword_45A0E4 = 0;
+				_animationFrameDelta = 1;
+				dword_45A0E8 = 3;
+				return true;
+			case 14:
+			case 17:
+			case 20:
+			case 21:
+			case 36:
+				_animationState = 16;
+				_animationFrame = 0;
+				return true;
+			case 15:
+				_animationState = 16;
+				_animationFrame = 16 - 16 * _animationFrame / 12;
+				return true;
+			case 16:
+			case 25:
+			case 26:
+			case 55:
+				return true;
+			case 60:
+				_animationState = 61;
+				return true;
+			default:
+				_animationState = 0;
+				_animationFrame = 0;
+				dword_45A0DC = 0;
+				return true;
+			}
 		} else {
+			if (_animationFrame <= 6) {
+				int v3 = Random_Query(0, 2);
+				int v4 = 0;
+				if (v3 == 0) {
+					v4 = 595;
+				} else if (v3 == 1) {
+					v4 = 594;
+				} else if (v3 == 2) {
+					v4 = 593;
+				}
+				Ambient_Sounds_Play_Sound(v4, 39, 0, 0, 99);
+			}
+			_animationState = 57;
 			_animationFrame = 0;
-			_animationState = 70;
+			return true;
 		}
-		return true;
-	case kAnimationModeFeeding:
-		_animationState = 55;
-		_animationFrame = 0;
-		return true;
-	case 51:
-		_animationState = 27;
-		_animationFrame = 0;
-		return true;
-	case 49:
-		_animationState = 28;
-		_animationFrame = 0;
-		return true;
-	case 48:
+	case kAnimationModeWalk:
+		if (_animationState != 27 && _animationState != 50) {
+			if (!Game_Flag_Query(550)) {
+				_animationState = 32;
+				_animationFrame = 0;
+			} else {
+				_animationState = 58;
+				_animationFrame = 0;
+			}
+		}
+		break;
+	case kAnimationModeRun:
+		if (_animationState != 27 && _animationState != 50) {
+			if (!Game_Flag_Query(550)) {
+				_animationState = 31;
+				_animationFrame = 0;
+			} else {
+				_animationState = 58;
+				_animationFrame = 4;
+			}
+		}
+		break;
+	case 3:
+		if (_animationState < 3 || _animationState > 12) {
+			_animationState = 13;
+			_animationStateNext = 3;
+			_animationNext = 20;
+		} else {
+			Game_Flag_Reset(236);
+			dword_45A0F0 = 4;
+			dword_45A0F4 = 20;
+		}
+		break;
+	case kAnimationModeCombatIdle:
 		switch (_animationState) {
 		case 14:
-			_animationState = 28;
-			_animationFrame = 0;
+		case 15:
+		case 19:
+		case 21:
 			break;
-		case 13:
-			_animationState = 22;
-			_animationFrame = 0;
-			return true;
-		case 10:
-			_animationState = 18;
-			_animationFrame = 8 * (13 - _animationFrame) / 13;
-			return true;
-		case 8:
-		case 9:
-		case 12:
-			return true;
-		case 11:
-			_animationState = 18;
+		case 16:
+			_animationState = 15;
+			_animationFrame = 12 - 12 * _animationFrame / 16;
+			break;
+		case 17:
+		case 20:
+			_animationState = 19;
 			_animationFrame = 0;
 			break;
-		case 7:
+		case 18:
+			_animationState = 19;
+			_animationFrame = 13 * ((8 - _animationFrame) / 8);
+			break;
+		case 22:
+			_animationState = 19;
+			_animationFrame = 41;
+			break;
+		case 36:
+		case 37:
+		case 40:
+		case 41:
+		case 51:
 			_animationState = 14;
 			_animationFrame = 0;
 			break;
-		case 0:
-		case 1:
-		case 2:
-		case 3:
-		case 4:
-		case 5:
-		case 6:
+		default:
 			_animationState = 15;
 			_animationFrame = 0;
 			break;
-		default:
-			if (_animationState != 50) {
-				_animationState = 27;
-				_animationFrame = 0;
-			}
-			break;
-		}
-		return true;
-	case 47:
-		_animationState = 41;
-		_animationFrame = 0;
-		return true;
-	case 46:
-		_animationState = 40;
-		_animationFrame = 0;
-		return true;
-	case 45:
-		_animationState = 39;
-		_animationFrame = 0;
-		return true;
-	case 44:
-		_animationState = 38;
-		_animationFrame = 0;
-		return true;
-	case 42:
-		_animationState = 46;
-		_animationFrame = 0;
-		Player_Loses_Control();
-		return true;
-	case 41:
-		_animationState = 45;
-		_animationFrame = 0;
-		return true;
-	case 40:
-		_animationState = 44;
-		_animationFrame = 0;
-		return true;
-	case 39:
-		_animationFrame = 0;
-		_animationState = 52;
-		if (Player_Query_Current_Set() == 27) {
-			_animationFrame = 23;
-		}
-		return true;
-	case 38:
-		_animationState = 47;
-		_animationFrame = 0;
-		return true;
-	case 29:
-		Player_Loses_Control();
-		_animationFrame = 0;
-		_animationState = 71;
-		return true;
-	case 23:
-		_animationState = 66;
-		_animationFrame = 0;
-		return true;
-	case 22:
-		if (Random_Query(0, 1)) {
-			_animationState = 23;
-		} else {
-			_animationState = 24;
 		}
-		_animationFrame = 0;
-		return true;
-	case 21:
+		break;
+	case 5:
 		switch (_animationState) {
-		case 0:
-		case 2:
-		case 3:
-		case 4:
-		case 5:
-		case 6:
-		case 7:
-			_animationState = 28;
-			_animationFrame = 0;
+		case 17:
+		case 18:
+		case 21:
 			break;
-		case 1:
-		case 8:
-			_animationState = 27;
+		case 19:
+			_animationState = 18;
+			_animationFrame = 8 * (13 - _animationFrame) / 13;
+			break;
+		case 22:
+			_animationState = 22;
 			_animationFrame = 0;
 			break;
 		default:
-
-			if (Random_Query(0, 1)) {
-				_animationState = 26;
-			} else {
-				_animationState = 25;
-			}
+			_animationState = 18;
 			_animationFrame = 0;
 			break;
 		}
-		return true;
-	case 20:
-		v2 = Actor_Query_Which_Set_In(kActorMcCoy);
-		if (v2 == 27) {
-			_animationState = 51;
+		break;
+	case kAnimationModeCombatShoot:
+		_animationState = 21;
+		_animationFrame = 0;
+		break;
+	case kAnimationModeCombatWalk:
+		if (_animationState != 27 && _animationState != 50) {
+			_animationState = 36;
 			_animationFrame = 0;
-			Player_Loses_Control();
-			Game_Flag_Set(210);
-		} else if (v2 == 70 || v2 == 87) {
-			_animationState = 56;
+		}
+		break;
+	case kAnimationModeCombatRun:
+		if (_animationState != 27 && _animationState != 50) {
+			_animationState = 37;
 			_animationFrame = 0;
 		}
-		return true;
-	case 19:
+		break;
+	case 9:
+	case 12:
 		if (_animationState < 3 || _animationState > 12) {
 			_animationState = 13;
-			_animationStateNext = 12;
+			_animationStateNext = 5;
+			_animationNext = 21;
+		} else {
+			Game_Flag_Reset(236);
+			dword_45A0F0 = 5;
+			dword_45A0F4 = 21;
+		}
+		break;
+	case 10:
+	case 13:
+		if (_animationState < 3 || _animationState > 12) {
+			_animationState = 13;
+			_animationStateNext = 6;
 			_animationNext = 27;
 		} else {
 			Game_Flag_Reset(236);
-			dword_45A0F0 = 12;
+			dword_45A0F0 = 6;
 			dword_45A0F4 = 27;
 		}
-		return true;
-	case 18:
+		break;
+	case 11:
+	case 14:
 		if (_animationState < 3 || _animationState > 12) {
 			_animationState = 13;
-			_animationStateNext = 11;
-			_animationNext = 26;
+			_animationStateNext = 7;
+			_animationNext = 22;
 		} else {
 			Game_Flag_Reset(236);
-			dword_45A0F0 = 11;
-			dword_45A0F4 = 26;
+			dword_45A0F0 = 7;
+			dword_45A0F4 = 22;
 		}
-		return true;
-	case 17:
+		break;
+	case 15:
 		if (_animationState < 3 || _animationState > 12) {
 			_animationState = 13;
-			_animationStateNext = 10;
-			_animationNext = 25;
+			_animationStateNext = 8;
+			_animationNext = 23;
 		} else {
 			Game_Flag_Reset(236);
-			dword_45A0F0 = 10;
-			dword_45A0F4 = 25;
+			dword_45A0F0 = 8;
+			dword_45A0F4 = 23;
 		}
-		return true;
+		break;
 	case 16:
 		if (_animationState < 3 || _animationState > 12) {
 			_animationState = 13;
@@ -1441,205 +1455,205 @@ bool AIScriptMcCoy::ChangeAnimationMode(int mode) {
 			dword_45A0F0 = 9;
 			dword_45A0F4 = 24;
 		}
-		return true;
-	case 15:
+		break;
+	case 17:
 		if (_animationState < 3 || _animationState > 12) {
 			_animationState = 13;
-			_animationStateNext = 8;
-			_animationNext = 23;
+			_animationStateNext = 10;
+			_animationNext = 25;
 		} else {
 			Game_Flag_Reset(236);
-			dword_45A0F0 = 8;
-			dword_45A0F4 = 23;
+			dword_45A0F0 = 10;
+			dword_45A0F4 = 25;
 		}
-		return true;
-	case 11:
-	case 14:
+		break;
+	case 18:
 		if (_animationState < 3 || _animationState > 12) {
 			_animationState = 13;
-			_animationStateNext = 7;
-			_animationNext = 22;
+			_animationStateNext = 11;
+			_animationNext = 26;
 		} else {
 			Game_Flag_Reset(236);
-			dword_45A0F0 = 7;
-			dword_45A0F4 = 22;
+			dword_45A0F0 = 11;
+			dword_45A0F4 = 26;
 		}
-		return true;
-	case 10:
-	case 13:
+		break;
+	case 19:
 		if (_animationState < 3 || _animationState > 12) {
 			_animationState = 13;
-			_animationStateNext = 6;
+			_animationStateNext = 12;
 			_animationNext = 27;
 		} else {
 			Game_Flag_Reset(236);
-			dword_45A0F0 = 6;
+			dword_45A0F0 = 12;
 			dword_45A0F4 = 27;
 		}
-		return true;
-	case 9:
-	case 12:
-		if (_animationState < 3 || _animationState > 12) {
-			_animationState = 13;
-			_animationStateNext = 5;
-			_animationNext = 21;
-		} else {
-			Game_Flag_Reset(236);
-			dword_45A0F0 = 5;
-			dword_45A0F4 = 21;
-		}
-		return true;
-	case kAnimationModeCombatRun:
-		if (_animationState != 27 && _animationState != 50) {
-			_animationState = 37;
-			_animationFrame = 0;
-		}
-		return true;
-	case kAnimationModeCombatWalk:
-		if (_animationState != 27 && _animationState != 50) {
-			_animationState = 36;
-			_animationFrame = 0;
-		}
-		return true;
-	case kAnimationModeCombatShoot:
-		_animationState = 21;
-		_animationFrame = 0;
-		return true;
-	case 5:
-		switch (_animationState) {
-		case 1:
-		case 2:
-		case 5:
-			_animationState = 14;
-			_animationFrame = 0;
-			break;
-		case 0:
-		case 3:
-		case 4:
-			_animationState = 15;
-			_animationFrame = 0;
-			break;
-		default:
-			_animationState = 18;
-			_animationFrame = 0;
-			break;
+		break;
+	case 20:
+		{
+			int setId = Actor_Query_Which_Set_In(kActorMcCoy);
+			if (setId == kSetCT02) {
+				_animationState = 51;
+				_animationFrame = 0;
+				Player_Loses_Control();
+				Game_Flag_Set(210);
+			} else if (setId == kSetRC03 || setId == kSetUG15) {
+				_animationState = 56;
+				_animationFrame = 0;
+			}
 		}
-		return true;
-	case kAnimationModeCombatIdle:
+		break;
+	case 21:
 		switch (_animationState) {
-		case 22:
-			_animationState = 19;
-			_animationFrame = 41;
-			break;
-		case 18:
-			_animationState = 19;
-			_animationFrame = 13 * ((8 - _animationFrame) / 8);
-			break;
+		case 14:
+		case 15:
 		case 17:
+		case 18:
+		case 19:
 		case 20:
-			_animationState = 19;
+		case 21:
+		case 22:
+			if (Random_Query(0, 1) == 1) {
+				_animationState = 24;
+			} else {
+				_animationState = 23;
+			}
 			_animationFrame = 0;
 			break;
 		case 16:
-			_animationState = 15;
-			_animationFrame = 12 - 12 * _animationFrame / 16;
+			if (Random_Query(0, 1) == 1) {
+				_animationState = 26;
+			} else {
+				_animationState = 25;
+			}
+			_animationFrame = 0;
 			break;
+		}
+		break;
+	case 22:
+		if (Random_Query(0, 1) == 1) {
+			_animationState = 23;
+		} else {
+			_animationState = 24;
+		}
+		_animationFrame = 0;
+		break;
+	case 23:
+		_animationState = 66;
+		_animationFrame = 0;
+		break;
+	case 29:
+		Player_Loses_Control();
+		_animationFrame = 0;
+		_animationState = 71;
+		break;
+	case 38:
+		_animationState = 47;
+		_animationFrame = 0;
+		break;
+	case 39:
+		_animationFrame = 0;
+		_animationState = 52;
+		if (Player_Query_Current_Set() == kSetCT02) {
+			_animationFrame = 23;
+		}
+		break;
+	case 40:
+		_animationState = 44;
+		_animationFrame = 0;
+		break;
+	case 41:
+		_animationState = 45;
+		_animationFrame = 0;
+		break;
+	case 42:
+		_animationState = 46;
+		_animationFrame = 0;
+		Player_Loses_Control();
+		break;
+	case 44:
+		_animationState = 38;
+		_animationFrame = 0;
+		break;
+	case 45:
+		_animationState = 39;
+		_animationFrame = 0;
+		break;
+	case 46:
+		_animationState = 40;
+		_animationFrame = 0;
+		break;
+	case 47:
+		_animationState = 41;
+		_animationFrame = 0;
+		break;
+	case 48:
+		switch (_animationState) {
 		case 14:
 		case 15:
+		case 17:
+		case 18:
 		case 19:
+		case 20:
 		case 21:
-		case 2:
-		case 3:
-			return true;
-		default:
-			_animationState = 15;
+		case 22:
+			_animationState = 28;
 			_animationFrame = 0;
 			break;
-		case 13:
-			_animationState = 16;
-			_animationFrame = 0;
+		case 27:
+		case 28:
+		case 50:
 			break;
-		case 0:
-		case 1:
-		case 4:
-		case 5:
-		case 6:
-		case 7:
-		case 8:
-		case 9:
-		case 10:
-		case 11:
-		case 12:
-			_animationState = 0;
+		default:
+			_animationState = 27;
 			_animationFrame = 0;
-			dword_45A0DC = 0;
 			break;
 		}
-		return true;
-	case 3:
-		if (_animationState >= 3 && _animationState <= 12) {
-			Game_Flag_Reset(236);
-			dword_45A0F0 = 4;
-			dword_45A0F4 = 20;
-		} else {
-			_animationState = 13;
-			_animationStateNext = 3;
-			_animationNext = 20;
-		}
-		return true;
-	case kAnimationModeRun:
-		if (_animationState == 27 || _animationState == 50) {
-			return true;
-		}
-		if (!Game_Flag_Query(550)) {
-			_animationState = 31;
+		break;
+	case 49:
+		_animationState = 28;
+		_animationFrame = 0;
+		break;
+	case 51:
+		_animationState = 27;
+		_animationFrame = 0;
+		break;
+	case 52:
+		_animationState = 55;
+		_animationFrame = 0;
+		break;
+	case 53:
+		if (_animationState != 60 && (Player_Query_Current_Set() == kSetNR03 || Player_Query_Current_Set() == kSetNR05_NR08)) {
+			_animationState = 60;
 			_animationFrame = 0;
-			return true;
-		}
-		_animationState = 58;
-		_animationFrame = 4;
-		return true;
-	case kAnimationModeWalk:
-		if (_animationState == 27 || _animationState == 50) {
-			return true;
-		}
-		if (!Game_Flag_Query(550)) {
-			_animationState = 32;
+		} else {
 			_animationFrame = 0;
-			return true;
+			_animationState = 70;
 		}
-		_animationState = 58;
+		break;
+	case 64:
+	case 66:
+		_animationState = 42;
 		_animationFrame = 0;
-		return true;
-	case kAnimationModeIdle:
-		if (Game_Flag_Query(550)) {
-			if (_animationFrame > 6) {
-				_animationState = 57;
-				_animationFrame = 0;
-				return true;
-			}
-			int v3 = Random_Query(0, 2);
-			int v4 = 0;
-			if (v3 == 0) {
-				v4 = 595;
-			} else if (v3 == 1) {
-				v4 = 594;
-			} else if (v3 == 2) {
-				v4 = 593;
-			}
-			Ambient_Sounds_Play_Sound(v4, 39, 0, 0, 99);
-			_animationState = 57;
-			_animationFrame = 0;
-			return true;
-		}
-		if (_animationState == 60) {
-			_animationState = 61;
-			return true;
-		}
-		_animationState = 0;
+		break;
+	case 65:
+	case 67:
+		_animationState = 43;
 		_animationFrame = 0;
-		dword_45A0DC = 0;
-		return true;
+		break;
+	case 68:
+		_animationState = 29;
+		_animationFrame = Slice_Animation_Query_Number_Of_Frames(18) - 1;
+		_animationFrameDelta = -1;
+		break;
+	case 75:
+		_animationState = 67;
+		_animationFrame = 0;
+		break;
+	case 85:
+		_animationFrame = 0;
+		_animationState = 69;
+		break;
 	}
 	return true;
 }
@@ -1679,7 +1693,7 @@ void AIScriptMcCoy::sub_4053E0() {
 }
 
 void AIScriptMcCoy::sub_4054F0() {
-	if (Actor_Query_Which_Set_In(kActorMcCoy) == 87 && Actor_Query_Goal_Number(kActorMcCoy) != 390 && !Game_Flag_Query(682)) {
+	if (Actor_Query_Which_Set_In(kActorMcCoy) == kSetUG15 && Actor_Query_Goal_Number(kActorMcCoy) != 390 && !Game_Flag_Query(682)) {
 		float x, y, z;
 		Actor_Query_XYZ(kActorMcCoy, &x, &y, &z);
 		if ((z < 220.0f) && (-210.0f < x) && (-70.0f > x)) {
@@ -1749,7 +1763,7 @@ void AIScriptMcCoy::sub_405660() {
 		dword_45A0D8 = 0;
 		dword_45A0DC = 30;
 		dword_45A0E4 = 0;
-		dword_45A0E0 = 1;
+		_animationFrameDelta = 1;
 		dword_45A0E8 = 3;
 		break;
 	case 60:
@@ -1802,13 +1816,13 @@ void AIScriptMcCoy::sub_405800() {
 }
 
 void AIScriptMcCoy::sub_4058B0() {
-	int v0 = Actor_Query_Which_Set_In(kActorMcCoy);
-	if (v0 == 27) {
+	int setId = Actor_Query_Which_Set_In(kActorMcCoy);
+	if (setId == kSetCT02) {
 		_animationState = 51;
 		_animationFrame = 0;
 		Player_Loses_Control();
 		Game_Flag_Set(210);
-	} else if (v0 == 70 || v0 == 87) {
+	} else if (setId == kSetRC03 || setId == kSetUG15) {
 		_animationState = 56;
 		_animationFrame = 0;
 	}
diff --git a/engines/bladerunner/script/ai/officer_leary.cpp b/engines/bladerunner/script/ai/officer_leary.cpp
index c95ba20..d51b7d8 100644
--- a/engines/bladerunner/script/ai/officer_leary.cpp
+++ b/engines/bladerunner/script/ai/officer_leary.cpp
@@ -24,6 +24,11 @@
 
 namespace BladeRunner {
 
+AIScriptOfficerLeary::AIScriptOfficerLeary(BladeRunnerEngine *vm) : AIScriptBase(vm) {
+	var_45D5B8 = 0;
+	var_45D5BC = 0;
+}
+
 void AIScriptOfficerLeary::Initialize() {
 	_animationState = 0;
 	_animationFrame = 0;
diff --git a/engines/bladerunner/script/ai/runciter.cpp b/engines/bladerunner/script/ai/runciter.cpp
index d1d7a08..18b7ae9 100644
--- a/engines/bladerunner/script/ai/runciter.cpp
+++ b/engines/bladerunner/script/ai/runciter.cpp
@@ -31,6 +31,14 @@ enum kRunciterStates {
 	kRunciterStateDead         = 15
 };
 
+AIScriptRunciter::AIScriptRunciter(BladeRunnerEngine *vm) : AIScriptBase(vm) {
+	var_45CD78 = 0;
+	var_45CD7C = 0;
+	var_45CD80 = 0;
+	var_45CD84 = 0;
+	var_45CD88 = 0;
+}
+
 void AIScriptRunciter::Initialize() {
 	_animationState = 0;
 	_animationFrame = 0;
diff --git a/engines/bladerunner/script/ai_script.h b/engines/bladerunner/script/ai_script.h
index 4be79c6..066de29 100644
--- a/engines/bladerunner/script/ai_script.h
+++ b/engines/bladerunner/script/ai_script.h
@@ -37,7 +37,12 @@ protected:
 	int _animationNext;
 
 public:
-	AIScriptBase(BladeRunnerEngine *vm) : ScriptBase(vm) {}
+	AIScriptBase(BladeRunnerEngine *vm) : ScriptBase(vm) {
+		_animationState = 0;
+		_animationFrame = 0;
+		_animationStateNext = 0;
+		_animationNext = 0;
+	}
 
 	virtual void Initialize() = 0;
 	virtual bool Update() = 0;
@@ -65,9 +70,7 @@ public:
 #define DECLARE_SCRIPT(name) \
 class AIScript##name : public AIScriptBase { \
 public: \
-	AIScript##name(BladeRunnerEngine *vm) \
-		: AIScriptBase(vm) \
-	{} \
+	AIScript##name(BladeRunnerEngine *vm); \
 	void Initialize(); \
 	bool Update(); \
 	void TimerExpired(int timer); \
@@ -95,7 +98,7 @@ private:
 DECLARE_SCRIPT(McCoy)
 	int dword_45A0D8;
 	int dword_45A0DC;
-	int dword_45A0E0;
+	int _animationFrameDelta;
 	int dword_45A0E4;
 	float off_45A0EC;
 	int dword_45A0E8;
diff --git a/engines/bladerunner/script/kia_script.cpp b/engines/bladerunner/script/kia_script.cpp
index 44d5666..13c5300 100644
--- a/engines/bladerunner/script/kia_script.cpp
+++ b/engines/bladerunner/script/kia_script.cpp
@@ -654,14 +654,14 @@ void KIAScript::SCRIPT_KIA_DLL_Play_Clue_Asset_Script(int notUsed, int clueId) {
 	case kClueDNALutherLance:
 	case kClueDNAMarcus:
 		{
-			int v1 = Global_Variable_Query(48) - 1;
-			if (v1 == 1) {
+			int dnaEvidences = Global_Variable_Query(kVariableDNAEvidences);
+			if (dnaEvidences == 1) {
 				KIA_Play_Slice_Model(988);
-			} else if (v1 == 2) {
+			} else if (dnaEvidences == 2) {
 				KIA_Play_Slice_Model(990);
-			} else if (v1 == 3) {
+			} else if (dnaEvidences == 3) {
 				KIA_Play_Slice_Model(991);
-			} else if (v1 == 4) {
+			} else if (dnaEvidences >= 4) {
 				KIA_Play_Slice_Model(993);
 			}
 		}
diff --git a/engines/bladerunner/script/scene/ug05.cpp b/engines/bladerunner/script/scene/ug05.cpp
index e02b6ed..c3996dc 100644
--- a/engines/bladerunner/script/scene/ug05.cpp
+++ b/engines/bladerunner/script/scene/ug05.cpp
@@ -247,7 +247,7 @@ void SceneScriptUG05::sub_402218() {
 	Ambient_Sounds_Remove_All_Looping_Sounds(1);
 	if (v0 == kActorLucy) {
 		if (Game_Flag_Query(kFlagLucyIsReplicant)) {
-			if (Global_Variable_Query(48) > 3) {
+			if (Global_Variable_Query(kVariableDNAEvidences) > 3) {
 				Outtake_Play(kOuttakeEnd1B, false, -1);
 			} else {
 				Outtake_Play(kOuttakeEnd1C, false, -1);
@@ -257,7 +257,7 @@ void SceneScriptUG05::sub_402218() {
 		}
 	} else if (v0 == kActorDektora) {
 		if (Game_Flag_Query(kFlagDektoraIsReplicant)) {
-			if (Global_Variable_Query(48) > 3) {
+			if (Global_Variable_Query(kVariableDNAEvidences) > 3) {
 				Outtake_Play(kOuttakeEnd1E, false, -1);
 			} else {
 				Outtake_Play(kOuttakeEnd1F, false, -1);





More information about the Scummvm-git-logs mailing list