ScummVM API documentation
actor.h
1 /* ScummVM - Graphic Adventure Engine
2  *
3  * ScummVM is the legal property of its developers, whose names
4  * are too numerous to list here. Please refer to the COPYRIGHT
5  * file distributed with this source distribution.
6  *
7  * This program is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation, either version 3 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program. If not, see <http://www.gnu.org/licenses/>.
19  *
20  */
21 
22 #ifndef BLADERUNNER_ACTOR_H
23 #define BLADERUNNER_ACTOR_H
24 
25 #include "bladerunner/boundingbox.h"
26 #include "bladerunner/vector.h"
27 
28 #include "common/array.h"
29 #include "common/rect.h"
30 
31 namespace BladeRunner {
32 
33 class ActorClues;
34 class ActorCombat;
35 class ActorWalk;
36 class BladeRunnerEngine;
37 class BoundingBox;
38 class MovementTrack;
39 class SaveFileReadStream;
40 class SaveFileWriteStream;
41 class View;
42 
43 class Actor {
44  BladeRunnerEngine *_vm;
45 
46  static const int kActorTimers = 7;
47 
48 public:
49  BoundingBox _bbox;
50  Common::Rect _screenRectangle;
51  MovementTrack *_movementTrack;
52  ActorWalk *_walkInfo;
53  ActorCombat *_combatInfo;
54  ActorClues *_clues;
55 
56 private:
57  int _honesty;
58  int _intelligence;
59  int _stability;
60  int _combatAggressiveness;
61  int _goalNumber;
62  Common::Array<int> _friendlinessToOther;
63 
64  int _currentHP;
65  int _maxHP;
66 
67  int _id;
68  int _setId;
69  Vector3 _position;
70  int _facing; // [0, 1024)
71  int _targetFacing;
72  int _walkboxId;
73 
74  int _cluesLimit;
75  uint32 _timer4RemainDefault;
76 
77  // Flags
78  bool _isTarget;
79  bool _isInvisible;
80  bool _isImmuneToObstacles;
81  bool _mustReachWalkDestination;
82  bool _isRetired;
83  bool _inCombat;
84  bool _isMoving;
85  bool _damageAnimIfMoving;
86 
87  // Movement
88  bool _movementTrackPaused;
89  int _movementTrackNextWaypointId;
90  int32 _movementTrackNextDelay; // probably not used
91  int _movementTrackNextAngle; // fixed: used for AI_Movement_Track_Append_With_Facing - original: probably not used
92  bool _movementTrackNextRunning;
93 
94  int _movementTrackWalkingToWaypointId;
95  int32 _movementTrackDelayOnNextWaypoint;
96 
97  // Animation
98  int _width;
99  int _height;
100  int _animationMode;
101  int _animationModeCombatIdle;
102  int _animationModeCombatWalk;
103  int _animationModeCombatRun;
104  int _fps;
105  int _frameMs;
106  int _animationId;
107  int _animationFrame;
108 
109  int _retiredWidth;
110  int _retiredHeight;
111 
112  int32 _timersLeft[kActorTimers]; // this keeps time difference, and it is stored during save() (saveInt actually saves a uint32)
113  uint32 _timersLast[kActorTimers]; // this keeps actual time, and is not stored during save(), so it can be a uint32
114 
115  float _scale;
116 
117  Vector3 _actorSpeed;
118 
119  int _sitcomRatio;
120 
121 public:
122  Actor(BladeRunnerEngine *_vm, int actorId);
123  ~Actor();
124 
125  void setup(int actorId);
126 
127  void setAtXYZ(const Vector3 &pos, int facing, bool setFacing = true, bool moving = false, bool retired = false);
128  void setAtWaypoint(int waypointId, int angle, bool moving, bool retired);
129 
130  int getId() const { return _id; };
131  float getX() const;
132  float getY() const;
133  float getZ() const;
134  Vector3 getXYZ() const;
135  int getFacing() const;
136  int getAnimationMode() const;
137  int getAnimationId() const;
138 
139  Vector3 getPosition() const { return _position; }
140 
141  void changeAnimationMode(int animationMode, bool force = false);
142  void changeAnimationState(int animationState, int animationFrame, int animationStateNext, int animationNext); // new for debugging purposes
143  void queryAnimationState(int *animationState, int *animationFrame, int *animationStateNext, int *animationNext); // new for debugging purposes
144  int getFPS() const;
145  void setFPS(int fps);
146  void increaseFPS();
147 
148  void timerStart(int timerId, int32 intervalMillis);
149  void timerReset(int timerId);
150  int32 timerLeft(int timerId);
151  void timersUpdate();
152  void timerUpdate(int timerId);
153 
154  void movementTrackNext(bool omitAiScript);
155  void movementTrackPause();
156  void movementTrackUnpause();
157  void movementTrackWaypointReached();
158 
159  bool loopWalk(const Vector3 &destination, int proximity, bool interruptible, bool runFlag, const Vector3 &start, float targetWidth, float targetSize, bool mustReach, bool *isRunningFlag, bool async);
160  bool walkTo(bool runFlag, const Vector3 &destination, bool mustReach);
161  bool loopWalkToActor(int otherActorId, int proximity, int interruptible, bool runFlag, bool mustReach, bool *isRunningFlag);
162  bool loopWalkToItem(int itemId, int proximity, int interruptible, bool runFlag, bool mustReach, bool *isRunningFlag);
163  bool loopWalkToSceneObject(const Common::String &objectName, int proximity, bool interruptible, bool runFlag, bool mustReach, bool *isRunningFlag);
164  bool loopWalkToWaypoint(int waypointId, int proximity, int interruptible, bool runFlag, bool mustReach, bool *isRunningFlag);
165  bool loopWalkToXYZ(const Vector3 &destination, int proximity, bool interruptible, bool runFlag, bool mustReach, bool *isRunningFlag);
166  bool asyncWalkToWaypoint(int waypointId, int proximity, bool runFlag, bool mustReach);
167  void asyncWalkToXYZ(const Vector3 &destination, int proximity, bool runFlag, bool mustReach);
168  void run();
169 
170  bool tick(bool forceUpdate, Common::Rect *screenRect);
171  void tickCombat();
172  bool draw(Common::Rect *screenRect);
173 
174  void resetScreenRectangleAndBbox();
175 
176  int getSetId() const;
177  void setSetId(int setId);
178  const BoundingBox &getBoundingBox() const { return _bbox; }
179  const Common::Rect &getScreenRectangle() { return _screenRectangle; }
180  int getWalkbox() const { return _walkboxId; }
181 
182  bool isRetired() const { return _isRetired; }
183  bool isTarget() const { return _isTarget; }
184  void setTarget(bool targetable);
185  bool isImmuneToObstacles() const { return _isImmuneToObstacles; }
186  bool inCombat() const { return _inCombat; }
187 
188  bool isMoving() const { return _isMoving; }
189  void setMoving(bool value) { _isMoving = value; }
190 
191  bool mustReachWalkDestination() const { return _mustReachWalkDestination; }
192  bool isWalking() const;
193  bool isRunning() const;
194  void stopWalking(bool value);
195 
196  void faceActor(int otherActorId, bool animate);
197  void faceObject(const Common::String &objectName, bool animate);
198  void faceItem(int itemId, bool animate);
199  void faceWaypoint(int waypointId, bool animate);
200  void faceXYZ(float x, float y, float z, bool animate);
201  void faceXYZ(const Vector3 &pos, bool animate);
202  void faceCurrentCamera(bool animate);
203  void faceHeading(int heading, bool animate);
204  void setFacing(int facing, bool halfOrSet = true);
205 
206  int getCurrentHP() const { return _currentHP; }
207  int getMaxHP() const { return _maxHP; }
208  void setCurrentHP(int hp);
209  void setHealth(int hp, int maxHp);
210  void modifyCurrentHP(signed int change);
211  void modifyMaxHP(signed int change);
212 
213  int getFriendlinessToOther(int otherActorId) const { return _friendlinessToOther[otherActorId]; }
214  void setFriendlinessToOther(int otherActorId, int friendliness);
215  void modifyFriendlinessToOther(int otherActorId, signed int change);
216  bool checkFriendlinessAndHonesty(int otherActorId);
217 
218  int getHonesty() const { return _honesty; }
219  void setHonesty(int honesty);
220  void modifyHonesty(signed int change);
221 
222  int getIntelligence() const { return _intelligence; }
223  void setIntelligence(int intelligence);
224  void modifyIntelligence(signed int change);
225 
226  int getStability() const { return _stability; }
227  void setStability(int stability);
228  void modifyStability(signed int change);
229 
230  int getCombatAggressiveness() const { return _combatAggressiveness; }
231  void setCombatAggressiveness(int combatAggressiveness);
232  void modifyCombatAggressiveness(signed int change);
233 
234  void setInvisible(bool isInvisible);
235  void setImmunityToObstacles(bool isImmune);
236 
237  void setFlagDamageAnimIfMoving(bool value);
238  bool getFlagDamageAnimIfMoving() const;
239 
240  int getSitcomRatio() const;
241 
242  void retire(bool isRetired, int width, int height, int retiredByActorId);
243 
244  void combatModeOn(int initialState, bool rangedAttack, int enemyId, int waypointType, int animationModeCombatIdle, int animationModeCombatWalk, int animationModeCombatRun, int fleeRatio, int coverRatio, int attackRatio, int damage, int range, bool unstoppable);
245  void combatModeOff();
246 
247  void setGoal(int goalNumber);
248  int getGoal() const;
249 
250  float distanceFromActor(int otherActorId);
251  int angleTo(const Vector3 &target) const;
252 
253  void speechPlay(int sentenceId, bool voiceOver);
254  void speechStop();
255  bool isSpeeching();
256 
257  void addClueToDatabase(int clueId, int unknown, bool clueAcquired, bool unknownFlag, int fromActorId);
258  bool canAcquireClue(int clueId) const;
259  void acquireClue(int clueId, bool unknownFlag, int fromActorId);
260  void loseClue(int clueId);
261  bool hasClue(int clueId) const;
262  bool copyClues(int actorId);
263  void acquireCluesByRelations();
264 
265  int soundVolume() const;
266  int soundPan(uint8 overrideRange = 35) const;
267 
268  bool isObstacleBetween(const Vector3 &target);
269 
270  void save(SaveFileWriteStream &f);
271  void load(SaveFileReadStream &f);
272 
273  static int findTargetUnderMouse(BladeRunnerEngine *vm, int mouseX, int mouseY);
274 
275 private:
276  void setBoundingBox(const Vector3 &position, bool retired);
277  float distanceFromView(View *view) const;
278 
279  bool findEmptyPositionAround(const Vector3 &startPosition, const Vector3 &targetPosition, float size, Vector3 *emptyPosition);
280  bool findNearestPosition(Vector3 *nearestPosition, float targetWidth, int proximity, float targetSize, const Vector3 &startPosition, const Vector3 &targetPosition);
281  bool stepAway(const Vector3 &destination, float distance);
282  //bool walkFindU3(int actorId, Vector3 from, int distance, Vector3 *out);
283 };
284 
285 } // End of namespace BladeRunner
286 
287 #endif
Definition: savefile.h:88
Definition: actor_clues.h:33
Definition: view.h:33
Definition: str.h:59
Definition: actor.h:31
Definition: savefile.h:113
Definition: rect.h:144
Definition: actor_walk.h:34
Definition: boundingbox.h:31
Definition: actor.h:43
Definition: vector.h:47
Definition: movement_track.h:34
Definition: bladerunner.h:113
Definition: actor_combat.h:33