From 7d2b9df5f2eb4a4b0639b00714c58b58fc200123 Mon Sep 17 00:00:00 2001 From: Eugene Sandulenko Date: Fri, 30 Mar 2018 00:25:25 +0200 Subject: BLADERUNNER: Initial code for acquireCluesByRelations() --- engines/bladerunner/actor.cpp | 38 ++++++++++++++++++++++++++++++++----- engines/bladerunner/actor.h | 4 ++++ engines/bladerunner/actor_clues.cpp | 4 ++++ engines/bladerunner/actor_clues.h | 2 ++ 4 files changed, 43 insertions(+), 5 deletions(-) diff --git a/engines/bladerunner/actor.cpp b/engines/bladerunner/actor.cpp index 998791d88a..538037f461 100644 --- a/engines/bladerunner/actor.cpp +++ b/engines/bladerunner/actor.cpp @@ -96,6 +96,8 @@ void Actor::setup(int actorId) { _retiredHeight = 0; _scale = 1.0f; + _timer4RemainDefault = 60000; + _movementTrackWalkingToWaypointId = -1; _movementTrackDelayOnNextWaypoint = -1; @@ -119,9 +121,6 @@ void Actor::setup(int actorId) { _movementTrackNextAngle = -1; _movementTrackNextRunning = false; - // Timer for exchanging clues - _timersLeft[4] = 60000; - _animationMode = -1; _screenRectangle = Common::Rect(-1, -1, -1, -1); @@ -225,6 +224,8 @@ void Actor::timerUpdate(int timerId) { break; case 4: // Exchange clues between actors + acquireCluesByRelations(); + _timersLeft[4] = _timer4RemainDefault; break; case 5: // Actor animation frame timer @@ -885,6 +886,21 @@ void Actor::setFriendlinessToOther(int otherActorId, int friendliness) { _friendlinessToOther[otherActorId] = friendliness; } +bool Actor::checkFriendlinessAndHonesty(int otherActorId) { + int honestyDiff = 2 * _friendlinessToOther[otherActorId] - _honesty; + int friendlinessRange; + + if (honestyDiff > 30) { + friendlinessRange = 100; + } else if (honestyDiff >= 0 && honestyDiff <= 30) { + friendlinessRange = 50; + } else { + friendlinessRange = 0; + } + + return _vm->_rnd.getRandomNumberRng(1, 100) <= friendlinessRange; +} + void Actor::setHonesty(int honesty) { _honesty = honesty; } @@ -1119,6 +1135,18 @@ void Actor::copyClues(int actorId) { } } +void Actor::acquireCluesByRelations() { + if (_setId >= 0 && _setId != kSetFreeSlotG && _setId != _vm->_actors[0]->_setId) { + for (int i = 0; i < _vm->_gameInfo->getActorCount(); i++) { + if (i != _id && _vm->_actors[i]->_setId == _setId && i && _id + && checkFriendlinessAndHonesty(i) + && _vm->_actors[0]->checkFriendlinessAndHonesty(_id)) { + _clues->acquireCluesByRelations(_id, i); + } + } + } +} + int Actor::soundVolume() const { float dist = distanceFromView(_vm->_view); return 35.0f * CLIP(1.0f - (dist / 1200.0f), 0.0f, 1.0f); @@ -1227,7 +1255,7 @@ void Actor::save(SaveFileWriteStream &f) { f.writeVector3(_position); f.writeInt(_facing); f.writeInt(_targetFacing); - f.writeInt(0); // TODO: _timer4RemainDefault + f.writeInt(_timer4RemainDefault); f.writeInt(_honesty); f.writeInt(_intelligence); @@ -1303,7 +1331,7 @@ void Actor::load(SaveFileReadStream &f) { _position = f.readVector3(); _facing = f.readInt(); _targetFacing = f.readInt(); - f.skip(4); // TODO: _timer4RemainDefault + _timer4RemainDefault = f.readInt(); _honesty = f.readInt(); _intelligence = f.readInt(); diff --git a/engines/bladerunner/actor.h b/engines/bladerunner/actor.h index 7498d2bf51..6540c0593a 100644 --- a/engines/bladerunner/actor.h +++ b/engines/bladerunner/actor.h @@ -70,6 +70,8 @@ private: int _targetFacing; int _walkboxId; + int _timer4RemainDefault; + // Flags bool _isTarget; bool _isInvisible; @@ -200,6 +202,7 @@ public: int getFriendlinessToOther(int otherActorId) const { return _friendlinessToOther[otherActorId]; } void setFriendlinessToOther(int otherActorId, int friendliness); void modifyFriendlinessToOther(int otherActorId, signed int change); + bool checkFriendlinessAndHonesty(int otherActorId); int getHonesty() const { return _honesty; } void setHonesty(int honesty); @@ -243,6 +246,7 @@ public: void loseClue(int clueId); bool hasClue(int clueId) const; void copyClues(int actorId); + void acquireCluesByRelations(); int soundVolume() const; int soundBalance() const; diff --git a/engines/bladerunner/actor_clues.cpp b/engines/bladerunner/actor_clues.cpp index 0c25ffc19f..3665f4de09 100644 --- a/engines/bladerunner/actor_clues.cpp +++ b/engines/bladerunner/actor_clues.cpp @@ -88,6 +88,10 @@ bool ActorClues::isAcquired(int clueId) const { #endif } +void ActorClues::acquireCluesByRelations(int actorId, int otherActorId) { + warning("TODO: acquireCluesByRelations"); +} + int ActorClues::getFromActorId(int clueId) const { int clueIndex = findClueIndex(clueId); if (clueIndex == -1) { diff --git a/engines/bladerunner/actor_clues.h b/engines/bladerunner/actor_clues.h index 79181cc20c..8bf9011937 100644 --- a/engines/bladerunner/actor_clues.h +++ b/engines/bladerunner/actor_clues.h @@ -60,6 +60,8 @@ public: void lose(int clueId); bool isAcquired(int clueId) const; + void acquireCluesByRelations(int actorId, int otherActorId); + int getFromActorId(int clueId) const; bool isFlag2(int clueId) const; -- cgit v1.2.3