ScummVM API documentation
player.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_PLAYER_H
23 #define NUVIE_CORE_PLAYER_H
24 
25 #include "ultima/nuvie/core/obj_manager.h"
26 #include "ultima/nuvie/actors/actor.h"
27 
28 namespace Ultima {
29 namespace Nuvie {
30 
31 #define MOVE_COST_USE 5
32 
33 class Configuration;
34 class GameClock;
35 class Actor;
36 class ActorManager;
37 class MapWindow;
38 class Party;
39 class NuvieIO;
40 
41 class Player {
42  const Configuration *config;
43  int game_type;
44  GameClock *_clock;
45  Party *party;
46  bool party_mode;
47  bool mapwindow_centered;
48  Actor *actor;
49  ActorManager *actor_manager;
50  ObjManager *obj_manager;
51 
52 // char name[14]; We can get the name from the player actor. --SB-X
53  uint8 gender;
54 
55  uint8 questf;
56  uint8 karma;
57  uint8 gargishf; // learned Gargish
58  uint8 alcohol; // number of alcoholic drinks consumed
59 
60  MapWindow *map_window;
61 
62  sint8 current_weapon;
63 
64 public:
65 
66  Player(const Configuration *cfg);
67 
68  bool init(ObjManager *om, ActorManager *am, MapWindow *mw, GameClock *c, Party *p);
69  void init();
70  bool load(NuvieIO *objlist);
71  bool save(NuvieIO *objlist);
72 
73  Actor *find_actor();
74  void update_player(Actor *next_player);
75 
76  bool is_mapwindow_centered() const {
77  return mapwindow_centered;
78  }
79  void set_mapwindow_centered(bool state);
80 
81  bool is_in_vehicle() const {
82  return (get_actor()->get_actor_num() == 0);
83  }
84 
85  Party *get_party() {
86  return party;
87  }
88  bool set_party_mode(Actor *new_actor);
89  bool set_solo_mode(Actor *new_actor);
90  bool in_party_mode() const {
91  return party_mode;
92  }
93 
94  void set_karma(uint8 val) {
95  karma = val;
96  }
97  uint8 get_karma() const {
98  return karma;
99  }
100  void add_karma(uint8 val = 1);
101  void subtract_karma(uint8 val = 1);
102  void subtract_movement_points(uint8 points);
103  void add_alcohol(uint8 val = 1) {
104  alcohol = clamp_max(alcohol + val, 255);
105  }
106  void dec_alcohol(uint8 val = 1) {
107  if (alcohol > val) {
108  alcohol -= val;
109  } else {
110  alcohol = 0;
111  }
112  }
113 
114  void set_quest_flag(uint8 val) {
115  questf = val;
116  }
117  uint8 get_quest_flag() const {
118  return questf;
119  }
120  void set_gargish_flag(uint8 val) {
121  gargishf = val;
122  }
123  uint8 get_gargish_flag() const {
124  return gargishf;
125  }
126 
127  void set_actor(Actor *new_actor);
128  Actor *get_actor();
129  const Actor *get_actor() const;
130  void get_location(uint16 *ret_x, uint16 *ret_y, uint8 *ret_level) const;
131  uint8 get_location_level() const;
132 
133  const char *get_name();
134  void set_gender(uint8 val) {
135  gender = val;
136  }
137  const char *get_gender_title() const;
138  uint8 get_gender() const {
139  return gender;
140  }
141 
142  bool check_moveRelative(sint16 rel_x, sint16 rel_y);
143  void moveRelative(sint16 rel_x, sint16 rel_y, bool mouse_movement = false);
144  void try_open_door(uint16 x, uint16 y, uint8 z);
145  void move(sint16 new_x, sint16 new_y, uint8 new_level, bool teleport);
146  void moveLeft();
147  void moveRight();
148  void moveUp();
149  void moveDown();
150  void pass();
151  void repairShip();
152 
153  uint32 get_walk_delay() const;
154  bool check_walk_delay();
155 
156  bool weapon_can_hit(uint16 x, uint16 y);
157  void attack_select_init(bool use_attack_text = true);
158  bool attack_select_next_weapon(bool add_newline = false, bool use_attack_text = true);
159 
160  void attack(MapCoord target, Actor *target_actor);
161  sint8 get_current_weapon() const {
162  return current_weapon;
163  }
164 
165 protected:
166 
167  bool attack_select_weapon_at_location(sint8 location, bool add_newline = false, bool use_attack_text = true);
168 };
169 
170 } // End of namespace Nuvie
171 } // End of namespace Ultima
172 
173 #endif
Definition: map_window.h:73
Definition: actor.h:178
Definition: configuration.h:61
Definition: game_clock.h:49
Definition: player.h:41
Definition: party.h:92
Definition: actor_manager.h:42
Definition: detection.h:27
Definition: map.h:84
Definition: obj_manager.h:75
Definition: nuvie_io.h:32