Skip to content
Permalink
Browse files

BLADERUNNER: Officers and combat bugfixes part 1

The debug messages and comments will all be removed after this series of fixes
  • Loading branch information...
antoniou79 committed May 20, 2019
1 parent 5b2e6f6 commit 203d82a1a0382684884da0d6c285444605153802
@@ -871,7 +871,7 @@ void Actor::stopWalking(bool value) {
}

if (isWalking()) {
_walkInfo->stop(_id, true, _animationModeCombatIdle, 0);
_walkInfo->stop(_id, true, _animationModeCombatIdle, kAnimationModeIdle);
} else if (inCombat()) {
changeAnimationMode(_animationModeCombatIdle, false);
} else {
@@ -686,7 +686,7 @@ bool ActorCombat::findClosestPositionToEnemy(Vector3 &output) const {
Vector3 test = _enemyPosition + offsets[i];
float dist = distance(_actorPosition, test);
if ( min == -1.0f || dist < min) {
if (!_vm->_sceneObjects->existsOnXZ(_actorId, test.x, test.z, true, true) && _vm->_scene->_set->findWalkbox(test.x, test.z) >= 0) {
if (!_vm->_sceneObjects->existsOnXZ(_actorId + kSceneObjectOffsetActors, test.x, test.z, true, true) && _vm->_scene->_set->findWalkbox(test.x, test.z) >= 0) {
output = test;
min = dist;
}
@@ -73,12 +73,14 @@ bool ActorWalk::setup(int actorId, bool runFlag, const Vector3 &from, const Vect
} else {
stop(actorId, true, kAnimationModeCombatIdle, kAnimationModeIdle);
}
// debug("actor id: %d, arrived: %d - false setup 01", actorId, (*arrived)? 1:0);
return false;
}

if (r == -1) {
stop(actorId, true, kAnimationModeCombatIdle, kAnimationModeIdle);
*arrived = true;
// debug("actor id: %d, arrived: %d - false setup 02", actorId, (*arrived)? 1:0);
return false;
}

@@ -107,6 +109,7 @@ bool ActorWalk::setup(int actorId, bool runFlag, const Vector3 &from, const Vect
if (next.x == _current.x && next.z == _current.z) {
stop(actorId, true, kAnimationModeCombatIdle, kAnimationModeIdle);
*arrived = true;
// debug("actor id: %d, arrived: %d - false setup 03", actorId, (*arrived)? 1:0);
return false;
}

@@ -115,6 +118,7 @@ bool ActorWalk::setup(int actorId, bool runFlag, const Vector3 &from, const Vect
_running = runFlag;
_status = 2;

// debug("actor id: %d, arrived: %d - true setup 01", actorId, (*arrived)? 1:0);
return true;
}

@@ -201,6 +205,9 @@ bool ActorWalk::tick(int actorId, float stepDistance, bool mustReachWalkDestinat
if (nextIsCloseEnough) {
return false;
}
} else {
stop(actorId, true, kAnimationModeCombatIdle, kAnimationModeIdle); // too close
return true;
}
}

@@ -419,6 +426,7 @@ int ActorWalk::nextOnPath(int actorId, const Vector3 &from, const Vector3 &to, V
next = from;

if (distance(from, to) < 6.0) {
// debug("Id: %d Distance: %f::Result -1", actorId, distance(from, to));
return -1;
}

@@ -427,16 +435,19 @@ int ActorWalk::nextOnPath(int actorId, const Vector3 &from, const Vector3 &to, V
return 1;
}
if (_vm->_scene->_set->findWalkbox(to.x, to.z) == -1) {
// debug("Id: %d No walkbox::Result 0", actorId);
return 0;
}
if (_vm->_sceneObjects->existsOnXZ(actorId + kSceneObjectOffsetActors, to.x, to.z, false, false)) {
// debug("Actor Id: %d existsOnXZ::Result 0", actorId);
return 0;
}
Vector3 next1;
if (_vm->_obstacles->findNextWaypoint(from, to, &next1)) {
next = next1;
return 1;
}
// debug("Id: %d DEFAULTED::Result 0", actorId);
return 0;
}

@@ -1580,7 +1580,7 @@ bool Debugger::cmdList(int argc, const char **argv) {
actor->getAnimationId(),
actor->getPosition().x,
actor->getPosition().y,
_vm->_actors[sceneObject->id - kSceneObjectOffsetActors]->getPosition().z);
actor->getPosition().z);
++count;
}
}
@@ -27,6 +27,8 @@
#include "bladerunner/obstacles.h"
#include "bladerunner/savefile.h"
#include "bladerunner/view.h"
//#include "bladerunner/scene.h" // asdf to REMOVE
//#include "bladerunner/game_constants.h" // asdf to REMOVE

namespace BladeRunner {

@@ -144,9 +146,9 @@ bool SceneObjects::existsOnXZ(int exceptSceneObjectId, float x, float z, bool mo
if (sceneObject->isRetired) {
isObstacle = false;
} else if (sceneObject->isMoving) {
isObstacle = movingActorIsObstacle != 0;
isObstacle = movingActorIsObstacle;
} else {
isObstacle = standingActorIsObstacle != 0;
isObstacle = standingActorIsObstacle;
}
} else {
isObstacle = sceneObject->isObstacle;
@@ -156,6 +158,21 @@ bool SceneObjects::existsOnXZ(int exceptSceneObjectId, float x, float z, bool mo
float x1, y1, z1, x2, y2, z2;
sceneObject->boundingBox.getXYZ(&x1, &y1, &z1, &x2, &y2, &z2);
if (z1 <= zMax && z2 >= zMin && x1 <= xMax && x2 >= xMin) {
// if (sceneObject->type == kSceneObjectTypeObject) {
// Vector3 a(x1,y1,z1);
// Vector3 b(x2,y2,z2);
// Vector3 pos = _vm->_view->calculateScreenPosition(0.5 * (a + b));
// debug("%d: %s (Clk: %s, Trg: %s, Prs: %s, Obs: %s, Mvg: %s), Pos(%02.2f,%02.2f,%02.2f)\n Bbox(%02.2f,%02.2f,%02.2f) ~ (%02.2f,%02.2f,%02.2f)\n",
// sceneObject->id - kSceneObjectOffsetObjects,
// _vm->_scene->objectGetName(sceneObject->id - kSceneObjectOffsetObjects).c_str(),
// sceneObject->isClickable? "T" : "F",
// sceneObject->isTarget? "T" : "F",
// sceneObject->isPresent? "T" : "F",
// sceneObject->isObstacle? "T" : "F",
// sceneObject->isMoving? "T" : "F",
// pos.x, pos.y, pos.z,
// a.x, a.y, a.z, b.x, b.y, b.z);
// }
return true;
}
}
@@ -21,6 +21,7 @@
*/

#include "bladerunner/script/ai_script.h"
//#include "common/debug.h"
namespace BladeRunner {

AIScriptOfficerGrayford::AIScriptOfficerGrayford(BladeRunnerEngine *vm) : AIScriptBase(vm) {
@@ -112,6 +113,7 @@ bool AIScriptOfficerGrayford::Update() {
switch (Actor_Query_Which_Set_In(kActorOfficerGrayford)) {
case kSetRC03:
if (Actor_Query_Which_Set_In(kActorOfficerGrayford) == Player_Query_Current_Set()) {
// asdf restore
Actor_Set_Goal_Number(kActorOfficerGrayford, kGoalOfficerGrayfordAttackMcCoyAct4);
Non_Player_Actor_Combat_Mode_On(kActorOfficerGrayford, kActorCombatStateIdle, true, kActorMcCoy, 18, kAnimationModeCombatIdle, kAnimationModeCombatWalk, kAnimationModeCombatRun, -1, -1, -1, 10, 300, false);
}
@@ -134,14 +136,14 @@ bool AIScriptOfficerGrayford::Update() {
Non_Player_Actor_Combat_Mode_On(kActorOfficerGrayford, kActorCombatStateIdle, true, kActorMcCoy, 10, kAnimationModeCombatIdle, kAnimationModeCombatWalk, kAnimationModeCombatRun, -1, -1, -1, 10, 300, false);
}
break;
// asdf UG07 whould be a type 10 combat, 12 flee?
// asdf missing UG07 case - would be a type 10 combat, 12 flee?
case kSetUG08:
if (Actor_Query_Which_Set_In(kActorOfficerGrayford) == Player_Query_Current_Set()) {
Actor_Set_Goal_Number(kActorOfficerGrayford, kGoalOfficerGrayfordAttackMcCoyAct4);
Non_Player_Actor_Combat_Mode_On(kActorOfficerGrayford, kActorCombatStateIdle, true, kActorMcCoy, 13, kAnimationModeCombatIdle, kAnimationModeCombatWalk, kAnimationModeCombatRun, -1, -1, -1, 10, 300, false);
}
break;
// asdf UG09 whould be a type ?? //
// asdf missing UG09 case - would be a type ?? //

case kSetUG10:
if (Actor_Query_Which_Set_In(kActorOfficerGrayford) == Player_Query_Current_Set()) {
@@ -268,6 +270,7 @@ void AIScriptOfficerGrayford::CompletedMovementTrack() {
break;

case kGoalOfficerGrayfordHuntingAroundAct4:
// debug("Grayford completed Movement");
Actor_Set_Goal_Number(kActorOfficerGrayford, kGoalOfficerGrayfordPrepareToHuntAroundAct4);
break;

@@ -326,9 +329,9 @@ void AIScriptOfficerGrayford::ClickedByPlayer() {
Actor_Face_Actor(kActorMcCoy, kActorOfficerGrayford, true);
Actor_Face_Actor(kActorOfficerGrayford, kActorMcCoy, true);
if (Random_Query(1, 2) == 1) {
Actor_Says(kActorMcCoy, 5075, 14);
Actor_Says(kActorMcCoy, 5075, 14); // Hey, pal.
} else {
Actor_Says(kActorMcCoy, 5075, 14); // bug in the original? Matches the above statement
Actor_Says(kActorMcCoy, 5075, 14); // Hey, pal. TODO asdf bug in the original? Matches the above statement
}
Actor_Set_Goal_Number(kActorOfficerGrayford, kGoalOfficerGrayfordWalksInPS03c);
break;
@@ -614,10 +617,13 @@ bool AIScriptOfficerGrayford::GoalChanged(int currentGoalNumber, int newGoalNumb
return true;

case kGoalOfficerGrayfordHuntingAroundAct4:
// debug("Flushing Grayford movement track");
AI_Movement_Track_Flush(kActorOfficerGrayford);
switch (Random_Query(1, 10)) {
switch (Random_Query(1, 10)) { // asdf restore
// switch (1) {
case 1:
// kSetNR01
// debug("gray 1 kSetNR01");
AI_Movement_Track_Append(kActorOfficerGrayford, 398, 15);
AI_Movement_Track_Append(kActorOfficerGrayford, 399, 0);
AI_Movement_Track_Append(kActorOfficerGrayford, 400, 0);
@@ -631,6 +637,7 @@ bool AIScriptOfficerGrayford::GoalChanged(int currentGoalNumber, int newGoalNumb

case 2:
// kSetCT11
// debug("gray 2 kSetCT11");
AI_Movement_Track_Append(kActorOfficerGrayford, 385, 10);
AI_Movement_Track_Append(kActorOfficerGrayford, 242, 2);
AI_Movement_Track_Append(kActorOfficerGrayford, 386, 2);
@@ -641,6 +648,7 @@ bool AIScriptOfficerGrayford::GoalChanged(int currentGoalNumber, int newGoalNumb

case 3:
// kSetDR01_DR02_DR04
// debug("gray 3 kSetDR01_DR02_DR04");
AI_Movement_Track_Append(kActorOfficerGrayford, 390, 10);
AI_Movement_Track_Append(kActorOfficerGrayford, 391, 0);
AI_Movement_Track_Append(kActorOfficerGrayford, 392, 5);
@@ -652,6 +660,7 @@ bool AIScriptOfficerGrayford::GoalChanged(int currentGoalNumber, int newGoalNumb

case 4:
// kSetRC03 -> kSetFreeSlotC
// debug("gray 4 kSetRC03 -> kSetFreeSlotC");
AI_Movement_Track_Append(kActorOfficerGrayford, 381, 15);
AI_Movement_Track_Append(kActorOfficerGrayford, 382, 0);
AI_Movement_Track_Append(kActorOfficerGrayford, 383, 15);
@@ -664,6 +673,7 @@ bool AIScriptOfficerGrayford::GoalChanged(int currentGoalNumber, int newGoalNumb

case 5:
// kSetBB01 -> kSetFreeSlotC
// debug("gray 5 kSetBB01 -> kSetFreeSlotC");
AI_Movement_Track_Append(kActorOfficerGrayford, 388, 10);
AI_Movement_Track_Append(kActorOfficerGrayford, 389, 10);
AI_Movement_Track_Append(kActorOfficerGrayford, 35, 30); // kSetFreeSlotC
@@ -673,6 +683,7 @@ bool AIScriptOfficerGrayford::GoalChanged(int currentGoalNumber, int newGoalNumb

case 6:
// kSetCT11 - identical to case 2
// debug("gray 6 kSetCT11");
AI_Movement_Track_Append(kActorOfficerGrayford, 385, 10);
AI_Movement_Track_Append(kActorOfficerGrayford, 242, 2);
AI_Movement_Track_Append(kActorOfficerGrayford, 386, 2);
@@ -700,16 +711,19 @@ bool AIScriptOfficerGrayford::GoalChanged(int currentGoalNumber, int newGoalNumb
return true;
#else
case 7:
// debug("gray 7 MA07 changed to kSetFreeSlotC");
// just put him away for a few seconds
AI_Movement_Track_Append(kActorOfficerGrayford, 35, 30); // kSetFreeSlotC
AI_Movement_Track_Repeat(kActorOfficerGrayford);
return true;
#endif // BLADERUNNER_ORIGINAL_BUGS

case 8:
switch (Random_Query(1, 7)) {
switch (Random_Query(1, 7)) { // asdf restore
// switch (1) {
case 1:
// kSetUG10 -> kSetFreeSlotC
// debug("gray 8-1 kSetUG10 -> kSetFreeSlotC");
AI_Movement_Track_Append(kActorOfficerGrayford, 302, 0);
AI_Movement_Track_Append(kActorOfficerGrayford, 407, 0);
AI_Movement_Track_Append(kActorOfficerGrayford, 408, 0);
@@ -719,6 +733,7 @@ bool AIScriptOfficerGrayford::GoalChanged(int currentGoalNumber, int newGoalNumb

case 2:
// kSetUG14
// debug("gray 8-2 kSetUG14");
AI_Movement_Track_Append(kActorOfficerGrayford, 536, 0);
AI_Movement_Track_Append(kActorOfficerGrayford, 537, 0);
AI_Movement_Track_Append(kActorOfficerGrayford, 538, 5);
@@ -729,6 +744,7 @@ bool AIScriptOfficerGrayford::GoalChanged(int currentGoalNumber, int newGoalNumb

case 3:
// kSetUG04 -> kSetFreeSlotC
// debug("gray 8-3 kSetUG04 -> kSetFreeSlotC");
AI_Movement_Track_Append(kActorOfficerGrayford, 296, 10);
AI_Movement_Track_Append(kActorOfficerGrayford, 409, 2);
AI_Movement_Track_Append(kActorOfficerGrayford, 296, 10);
@@ -738,6 +754,7 @@ bool AIScriptOfficerGrayford::GoalChanged(int currentGoalNumber, int newGoalNumb

case 4:
// kSetUG05 -> kSetFreeSlotC
// debug("gray 8-4 kSetUG05 -> kSetFreeSlotC");
AI_Movement_Track_Append(kActorOfficerGrayford, 411, 10);
AI_Movement_Track_Append(kActorOfficerGrayford, 412, 5);
AI_Movement_Track_Append(kActorOfficerGrayford, 411, 0);
@@ -747,6 +764,7 @@ bool AIScriptOfficerGrayford::GoalChanged(int currentGoalNumber, int newGoalNumb

case 5:
// kSetUG06 -> kSetFreeSlotC
// debug("gray 8-5 kSetUG06 -> kSetFreeSlotC");
AI_Movement_Track_Append(kActorOfficerGrayford, 413, 10);
AI_Movement_Track_Append(kActorOfficerGrayford, 414, 0);
AI_Movement_Track_Append_With_Facing(kActorOfficerGrayford, 431, 0, 1017);
@@ -757,6 +775,7 @@ bool AIScriptOfficerGrayford::GoalChanged(int currentGoalNumber, int newGoalNumb

case 6:
// kSetUG07 -> kSetFreeSlotC
// debug("gray 8-6 kSetUG07 -> kSetFreeSlotC");
AI_Movement_Track_Append(kActorOfficerGrayford, 415, 0);
AI_Movement_Track_Append_With_Facing(kActorOfficerGrayford, 416, 0, 620);
AI_Movement_Track_Append(kActorOfficerGrayford, 417, 0);
@@ -767,6 +786,7 @@ bool AIScriptOfficerGrayford::GoalChanged(int currentGoalNumber, int newGoalNumb

case 7:
// kSetUG01 -> kSetFreeSlotC
// debug("gray 8-7 kSetUG01 -> kSetFreeSlotC");
AI_Movement_Track_Append(kActorOfficerGrayford, 405, 10);
AI_Movement_Track_Append(kActorOfficerGrayford, 406, 0);
AI_Movement_Track_Append(kActorOfficerGrayford, 35, 30); // kSetFreeSlotC
@@ -781,15 +801,18 @@ bool AIScriptOfficerGrayford::GoalChanged(int currentGoalNumber, int newGoalNumb
return false; // does it matter if false or true? case 9 and 10 return false
#endif // BLADERUNNER_ORIGINAL_BUGS
case 9:
if (Random_Query(0, 1)) {
if (Random_Query(0, 1)) { // asdf restore
// if (1) {
// kSetUG09 -> kSetFreeSlotC
// debug("gray 9-1 kSetUG09 -> kSetFreeSlotC");
AI_Movement_Track_Append(kActorOfficerGrayford, 433, 10);
AI_Movement_Track_Append(kActorOfficerGrayford, 434, 0);
AI_Movement_Track_Append(kActorOfficerGrayford, 435, 0);
AI_Movement_Track_Append(kActorOfficerGrayford, 35, 30); // kSetFreeSlotC
AI_Movement_Track_Repeat(kActorOfficerGrayford);
} else {
// kSetUG08 -> kSetFreeSlotC
// debug("gray 9-0 kSetUG08 -> kSetFreeSlotC");
AI_Movement_Track_Append(kActorOfficerGrayford, 420, 10);
AI_Movement_Track_Append(kActorOfficerGrayford, 422, 2);
AI_Movement_Track_Append(kActorOfficerGrayford, 421, 1);
@@ -811,6 +834,7 @@ bool AIScriptOfficerGrayford::GoalChanged(int currentGoalNumber, int newGoalNumb

case 10:
// kSetUG12 -> kSetFreeSlotC
// debug("gray 10 kSetUG12 -> kSetFreeSlotC");
AI_Movement_Track_Append(kActorOfficerGrayford, 310, 0);
AI_Movement_Track_Append(kActorOfficerGrayford, 307, 0);
AI_Movement_Track_Append(kActorOfficerGrayford, 309, 0);
@@ -825,6 +849,7 @@ bool AIScriptOfficerGrayford::GoalChanged(int currentGoalNumber, int newGoalNumb
case kGoalOfficerGrayfordPrepareToHuntAroundAct4:
// aux goal in order to immediately switch back to kGoalOfficerGrayfordHuntingAroundAct4 goal
// and run GoalChanged() for kGoalOfficerGrayfordHuntingAroundAct4 again
// debug("Setting Grayford goal to kGoalOfficerGrayfordHuntingAroundAct4");
Actor_Set_Goal_Number(kActorOfficerGrayford, kGoalOfficerGrayfordHuntingAroundAct4);
return true;

@@ -1508,6 +1533,7 @@ void AIScriptOfficerGrayford::SetAnimationState(int animationState, int animatio
}

bool AIScriptOfficerGrayford::ReachedMovementTrackWaypoint(int waypointId) {
// debug("Grayford reached waypoint: %d", waypointId);
return true;
}

3 comments on commit 203d82a

@bluegr

This comment has been minimized.

Copy link
Member

replied May 20, 2019

What does asdf mean in this case? You keep using this. Is it some kind of FIXME/TODO comment?

@antoniou79

This comment has been minimized.

Copy link
Contributor Author

replied May 20, 2019

What does asdf mean in this case? You keep using this. Is it some kind of FIXME/TODO comment?

It's only a temporary string to quickly search for and locate stuff that I have to remove or restore. It will be gone in future commit

@sev-

This comment has been minimized.

Copy link
Member

replied May 20, 2019

Right, ETAOIN SHRDLU!

Please sign in to comment.
You can’t perform that action at this time.