[Scummvm-git-logs] scummvm master -> 7d2b9df5f2eb4a4b0639b00714c58b58fc200123

sev- sev at scummvm.org
Fri Mar 30 00:27:39 CEST 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:
7d2b9df5f2 BLADERUNNER: Initial code for acquireCluesByRelations()


Commit: 7d2b9df5f2eb4a4b0639b00714c58b58fc200123
    https://github.com/scummvm/scummvm/commit/7d2b9df5f2eb4a4b0639b00714c58b58fc200123
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2018-03-30T00:25:52+02:00

Commit Message:
BLADERUNNER: Initial code for acquireCluesByRelations()

Changed paths:
    engines/bladerunner/actor.cpp
    engines/bladerunner/actor.h
    engines/bladerunner/actor_clues.cpp
    engines/bladerunner/actor_clues.h


diff --git a/engines/bladerunner/actor.cpp b/engines/bladerunner/actor.cpp
index 998791d..538037f 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 7498d2b..6540c05 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 0c25ffc..3665f4d 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 79181cc..8bf9011 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;





More information about the Scummvm-git-logs mailing list