ScummVM API documentation
party.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 NUVIE_CORE_PARTY_H
23 #define NUVIE_CORE_PARTY_H
24 
25 #include "ultima/shared/std/string.h"
26 #include "ultima/nuvie/core/obj_manager.h"
27 #include "ultima/nuvie/core/map.h"
28 
29 namespace Ultima {
30 namespace Nuvie {
31 
32 class Configuration;
33 class Game;
34 class Actor;
35 class ActorManager;
36 class MapCoord;
37 class Map;
38 class NuvieIO;
39 class PartyPathFinder;
40 class PartySeek;
41 
42 typedef enum { TARGET_ACTOR, TARGET_LOCATION, TARGET_NONE } CombatTargetType;
43 
44 struct CombatTarget {
45  CombatTargetType type;
46  uint8 actor_num;
47  MapCoord loc;
48 };
49 
50 struct PartyMember {
51  char name[14];
52  Actor *actor;
53 //bool inactive; // true if not in formation
54  uint8 combat_position;
55  sint8 form_x; // relative position left or right of leader
56  sint8 form_y; // relative position in front or in back of leader
57  // (leader is at 0,0 in formation)
58  CombatTarget target;
59 };
60 
61 #define PARTY_MAX_MEMBERS 16
62 #define PARTY_NAME_MAX_LENGTH 13
63 
64 #define PARTY_KEEP_PARTY_FLAG true
65 
66 /* party walking formations: */
67 #define PARTY_FORM_STANDARD 0
68 #define PARTY_FORM_COLUMN 1
69 #define PARTY_FORM_ROW 2
70 #define PARTY_FORM_DELTA 3
71 #define PARTY_FORM_COMBAT 7
72 #define PARTY_FORM_REST 8
73 
74 /* 0 <- standard *
75  * 1 2 *
76  * 4 3 5 *
77  * 6 7 *
78  * *
79  * 0 <- column * 3210 <- row
80  * 1 * 7654
81  * 2 *
82  * 3... *
83  * *
84  * 0 <- delta
85  * 172
86  * 38 94
87  * 5A B6
88  *
89  * (Combat positions are dynamic, based on combat mode)
90  */
91 
92 class Party {
93 protected:
94  friend class PartyPathFinder;
95  Game *game; // get pointers here to avoid construct order issues in loadGame()
96  const Configuration *config;
97  ActorManager *actor_manager;
98  Map *map;
99  PartyPathFinder *pathfinder;
100 
101  PartyMember member[PARTY_MAX_MEMBERS];
102  uint8 lightsources;
103  uint8 num_in_party; // number of party members.
104  uint8 formation; // walking formation
105  uint16 prev_leader_x; // last location of leader
106  uint16 prev_leader_y;
107 
108  bool autowalk; // party is automatically walking to a destination
109  bool in_vehicle; //Party is in a vehicle.
110  bool in_combat_mode;
111 
112  bool defer_removing_dead_members;
113 
114  Obj *rest_campfire;
115 
116 public:
117 
118  Party(const Configuration *cfg);
119  virtual ~Party();
120 
121  virtual bool init(Game *g, ActorManager *am);
122  virtual bool load(NuvieIO *objlist);
123  virtual bool save(NuvieIO *objlist);
124 
125 // Basic methods
126  void follow(sint8 rel_x, sint8 rel_y); // follow in direction leader moved
127  bool move(uint16 dx, uint16 dy, uint8 dz);
128  void show(); // Actor::show()
129  void hide(); // Actor::hide()
130  virtual void dismount_from_horses();
131  virtual void update_music(); // set music depending on party location
132  virtual void split_gold();
133  virtual void gather_gold();
134  bool add_actor(Actor *actor);
135  bool remove_actor(Actor *actor, bool keep_party_flag = false);
136  bool remove_dead_actor(Actor *actor);
137  bool resurrect_dead_members();
138  void heal();
139  void cure();
140  void set_ethereal(bool ethereal);
141 //void set_active(uint8 member_num, bool state) { member[member_num].inactive = !state; }
142  uint8 get_formation() const {
143  return formation; // walking formation
144  }
145  void set_formation(uint8 val) {
146  formation = val;
147  reform_party();
148  }
149 // Properties
150  uint8 get_party_size();
151  virtual uint8 get_party_max() {
152  return 8; // U6
153  }
154  sint8 get_leader() const; // returns -1 if party has no leader and can't move
155  MapCoord get_leader_location() const;
156  MapCoord get_location(uint8 m = 0) const;
157  MapCoord get_formation_coords(uint8 m) const;
158  void set_in_vehicle(bool value);
159  void set_in_combat_mode(bool value);
160  bool is_in_vehicle() const {
161  return in_vehicle;
162  }
163  bool is_in_combat_mode() const {
164  return in_combat_mode;
165  }
166  Actor *get_slowest_actor(); // actor with lowest move count
167 
168 // Check specific actors
169  uint8 get_actor_num(uint8 member_num) const; //get actor id_n from party_member num.
170  Actor *get_actor(uint8 member_num) const;
171  sint8 get_member_num(const Actor *actor) const;
172  sint8 get_member_num(uint8 a) const;
173  Actor *get_leader_actor() const;
174  const char *get_actor_name(uint8 member_num) const;
175  bool is_leader(const Actor *actor) const {
176  return (get_member_num(actor) == get_leader());
177  }
178  bool contains_actor(const Actor *actor) const;
179  bool contains_actor(uint8 actor_num) const;
180 
181 // Check entire party
182  bool is_at(uint16 x, uint16 y, uint8 z, uint32 threshold = 0) const;
183  bool is_at(const MapCoord &xyz, uint32 threshold = 0) const;
184  bool is_anyone_at(uint16 x, uint16 y, uint8 z, uint32 threshold = 0) const;
185  bool is_anyone_at(const MapCoord &xyz, uint32 threshold = 0) const;
186  bool has_obj(uint16 obj_n, uint8 quality, bool match_zero_qual = true) const;
187  bool remove_obj(uint16 obj_n, uint8 quality);
188  Actor *who_has_obj(uint16 obj_n, uint8 quality, bool match_zero_qual = true);
189  Obj *get_obj(uint16 obj_n, uint8 quality, bool match_qual_zero = true, uint8 frame_n = 0, bool match_frame_n = false);
190  bool is_horsed() const; // is anyone on a horse?
191  bool is_everyone_horsed() const;
192  Obj *get_food(); // used while resting
193 
194 // Automatic-walking. These methods should be replaced with ActorActions.
195  void walk(MapCoord *walkto, MapCoord *teleport, uint32 step_delay = 0);
196  void walk(MapCoord *walkto, uint32 step_delay = 0) {
197  walk(walkto, nullptr, step_delay);
198  }
199  void walk(Obj *moongate, MapCoord *teleport, uint32 step_delay = 0);
200  void enter_vehicle(Obj *ship_obj, uint32 step_delay = 0);
201  void exit_vehicle(uint16 x, uint16 y, uint16 z);
202  void stop_walking(bool force_music_change);
203  bool get_autowalk() const {
204  return autowalk;
205  }
206  void rest_gather();
207  void rest_sleep(uint8 hours, sint16 guard);
208  bool can_rest(Std::string &err_str);
209 
210  void set_combat_target(uint8 member_num, Actor *target);
211  void set_combat_target(uint8 member_num, MapCoord target);
212  void clear_combat_target(uint8 member_num);
213  CombatTarget get_combat_target(uint8 member_num);
214  bool has_light_source();
215  void add_light_source() {
216  lightsources++; /* fprintf(stderr, "lightsources = %d\n", lightsources); */
217  }
218  void subtract_light_source() { /*assert(lightsources != 0);*/
219  lightsources--; /*fprintf(stderr, "lightsources = %d\n", lightsources); */
220  }
221  void update_light_sources();
222 
223  bool combat_changes_music, vehicles_change_music;
224 
225 protected:
226  void reform_party(); // call when adding or removing members
227 
228 };
229 
230 } // End of namespace Nuvie
231 } // End of namespace Ultima
232 
233 #endif
Definition: actor.h:178
Definition: party.h:44
Definition: obj.h:84
Definition: configuration.h:61
Definition: map.h:147
Definition: party.h:92
Definition: actor_manager.h:42
Definition: detection.h:27
Definition: party.h:50
Definition: string.h:30
Definition: map.h:84
Out move(In first, In last, Out dst)
Definition: algorithm.h:109
Definition: party_path_finder.h:51
Definition: nuvie_io.h:32
Definition: game.h:73