aboutsummaryrefslogtreecommitdiff
path: root/engines/bladerunner/actor.h
blob: 896f3a2e522318db4d222a3738161c4dd224259c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
/* ScummVM - Graphic Adventure Engine
 *
 * ScummVM is the legal property of its developers, whose names
 * are too numerous to list here. Please refer to the COPYRIGHT
 * file distributed with this source distribution.
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 *
 */

#ifndef BLADERUNNER_ACTOR_H
#define BLADERUNNER_ACTOR_H

#include "bladerunner/boundingbox.h"
#include "bladerunner/vector.h"

#include "common/array.h"
#include "common/rect.h"

namespace BladeRunner {

class ActorClues;
class ActorCombat;
class ActorWalk;
class BladeRunnerEngine;
class BoundingBox;
class MovementTrack;
class SaveFileReadStream;
class SaveFileWriteStream;
class View;

class Actor {
	BladeRunnerEngine *_vm;

public:
	BoundingBox    _bbox;
	Common::Rect   _screenRectangle;
	MovementTrack *_movementTrack;
	ActorWalk     *_walkInfo;
	ActorCombat   *_combatInfo;
	ActorClues    *_clues;

private:
	int                _honesty;
	int                _intelligence;
	int                _stability;
	int                _combatAggressiveness;
	int                _goalNumber;
	Common::Array<int> _friendlinessToOther;

	int _currentHP;
	int _maxHP;

	int     _id;
	int     _setId;
	Vector3 _position;
	int     _facing; // [0, 1024)
	int     _targetFacing;
	int     _walkboxId;

	int     _cluesLimit;
	int     _timer4RemainDefault;

	// Flags
	bool _isTarget;
	bool _isInvisible;
	bool _isImmuneToObstacles;
	bool _inWalkLoop;
	bool _isRetired;
	bool _inCombat;
	bool _isMoving;
	bool _damageAnimIfMoving;

	// Movement
	bool _movementTrackPaused;
	int  _movementTrackNextWaypointId;
	int  _movementTrackNextDelay; // probably not used
	int  _movementTrackNextAngle; // probably not used
	bool _movementTrackNextRunning;

	int _movementTrackWalkingToWaypointId;
	int _movementTrackDelayOnNextWaypoint;

	// Animation
	int _width;
	int _height;
	int _animationMode;
	int _animationModeCombatIdle;
	int _animationModeCombatWalk;
	int _animationModeCombatRun;
	int _fps;
	int _frameMs;
	int _animationId;
	int _animationFrame;

	int _retiredWidth;
	int _retiredHeight;

	int _timersLeft[7];
	int _timersLast[7];

	float _scale;

	Vector3 _actorSpeed;

public:
	Actor(BladeRunnerEngine *_vm, int actorId);
	~Actor();

	void setup(int actorId);

	void setAtXYZ(const Vector3 &pos, int facing, bool setFacing = true, bool moving = false, bool retired = false);
	void setAtWaypoint(int waypointId, int angle, int unknown, bool retired);

	float getX() const;
	float getY() const;
	float getZ() const;
	Vector3 getXYZ() const;
	int getFacing() const;
	int getAnimationMode() const;

	Vector3 getPosition() const { return _position; }

	void changeAnimationMode(int animationMode, bool force = false);
	void setFPS(int fps);
	void increaseFPS();

	void timerStart(int timerId, int interval);
	void timerReset(int timerId);
	int  timerLeft(int timerId);
	void timersUpdate();
	void timerUpdate(int timerId);

	void movementTrackNext(bool omitAiScript);
	void movementTrackPause();
	void movementTrackUnpause();
	void movementTrackWaypointReached();

	bool loopWalk(const Vector3 &destination, int destinationOffset, bool interruptible, bool runFlag, const Vector3 &start, float a6, float a7, bool a8, bool *isRunningFlag, bool async);
	bool walkTo(bool runFlag, const Vector3 &destination, bool a3);
	bool loopWalkToActor(int otherActorId, int destinationOffset, int interruptible, bool runFlag, bool a5, bool *isRunningFlag);
	bool loopWalkToItem(int itemId, int destinationOffset, int interruptible, bool runFlag, bool a5, bool *isRunningFlag);
	bool loopWalkToSceneObject(const Common::String &objectName, int destinationOffset, bool interruptible, bool runFlag, bool a5, bool *isRunningFlag);
	bool loopWalkToWaypoint(int waypointId, int destinationOffset, int interruptible, bool runFlag, bool a5, bool *isRunningFlag);
	bool loopWalkToXYZ(const Vector3 &destination, int destinationOffset, bool interruptible, bool runFlag, bool a5, bool *isRunningFlag);
	bool asyncWalkToWaypoint(int waypointId, int destinationOffset, bool runFlag, bool a5);
	void asyncWalkToXYZ(const Vector3 &destination, int destinationOffset, bool runFlag, int a6);
	void run();

	bool tick(bool forceUpdate, Common::Rect *screenRect);
	void tickCombat();
	bool draw(Common::Rect *screenRect);

	int getSetId()  const;
	void setSetId(int setId);
	const BoundingBox &getBoundingBox() const { return _bbox; }
	const Common::Rect &getScreenRectangle() { return _screenRectangle; }
	int getWalkbox() const { return _walkboxId; }

	bool isRetired() const { return _isRetired; }
	bool isTarget() const { return _isTarget; }
	void setTarget(bool targetable);
	bool isImmuneToObstacles() const { return _isImmuneToObstacles; }
	bool inCombat() const { return _inCombat; }

	bool isMoving() const { return _isMoving; }
	void setMoving(bool value) { _isMoving = value; }

	bool inWalkLoop() const { return _inWalkLoop; }
	bool isWalking() const;
	bool isRunning() const;
	void stopWalking(bool value);

	void faceActor(int otherActorId, bool animate);
	void faceObject(const Common::String &objectName, bool animate);
	void faceItem(int itemId, bool animate);
	void faceWaypoint(int waypointId, bool animate);
	void faceXYZ(float x, float y, float z, bool animate);
	void faceXYZ(const Vector3 &pos, bool animate);
	void faceCurrentCamera(bool animate);
	void faceHeading(int heading, bool animate);
	void setFacing(int facing, bool halfOrSet = true);

	int getCurrentHP() const { return _currentHP; }
	int getMaxHP() const { return _maxHP; }
	void setCurrentHP(int hp);
	void setHealth(int hp, int maxHp);
	void modifyCurrentHP(signed int change);
	void modifyMaxHP(signed int change);

	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);
	void modifyHonesty(signed int change);

	int getIntelligence() const { return _intelligence; }
	void setIntelligence(int intelligence);
	void modifyIntelligence(signed int change);

	int getStability() const { return _stability; }
	void setStability(int stability);
	void modifyStability(signed int change);

	int getCombatAggressiveness() const { return _combatAggressiveness; }
	void setCombatAggressiveness(int combatAggressiveness);
	void modifyCombatAggressiveness(signed int change);

	void setInvisible(bool isInvisible);
	void setImmunityToObstacles(bool isImmune);

	void setFlagDamageAnimIfMoving(bool value);
	bool getFlagDamageAnimIfMoving() const;

	void retire(bool isRetired, int width, int height, int retiredByActorId);

	void combatModeOn(int initialState, bool rangedAttack, int enemyId, int waypointType, int animationModeCombatIdle, int animationModeCombatWalk, int animationModeCombatRun, int fleeRatio, int coverRatio, int actionRatio, int damage, int range, bool unstoppable);
	void combatModeOff();

	void setGoal(int goalNumber);
	int getGoal() const;

	float distanceFromActor(int otherActorId);
	int angleTo(const Vector3 &target) const;

	void speechPlay(int sentenceId, bool voiceOver);
	void speechStop();
	bool isSpeeching();

	void addClueToDatabase(int clueId, int unknown, bool clueAcquired, bool unknownFlag, int fromActorId);
	bool canAcquireClue(int clueId) const;
	void acquireClue(int clueId, bool unknownFlag, int fromActorId);
	void loseClue(int clueId);
	bool hasClue(int clueId) const;
	void copyClues(int actorId);
	void acquireCluesByRelations();

	int soundVolume() const;
	int soundBalance() const;

	bool isObstacleBetween(const Vector3 &target);

	void save(SaveFileWriteStream &f);
	void load(SaveFileReadStream &f);

	static int findTargetUnderMouse(BladeRunnerEngine *vm, int mouseX, int mouseY);

private:
	void setBoundingBox(const Vector3 &position, bool retired);
	float distanceFromView(View *view) const;

	bool walkFindU1(const Vector3 &startPosition, const Vector3 &targetPosition, float a3, Vector3 *newDestination);
	bool walkFindU2(Vector3 *newDestination, float targetWidth, int destinationOffset, float targetSize, const Vector3 &startPosition, const Vector3 &targetPosition);
	bool walkToNearestPoint(const Vector3 &destination, float distance);
	//bool walkFindU3(int actorId, Vector3 from, int distance, Vector3 *out);
};

} // End of namespace BladeRunner

#endif