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 ULTIMA4_GAME_PLAYER_H
23#define ULTIMA4_GAME_PLAYER_H
24
25#include "ultima/ultima4/game/creature.h"
26#include "ultima/ultima4/map/direction.h"
27#include "ultima/ultima4/core/observable.h"
28#include "ultima/ultima4/filesys/savegame.h"
29#include "ultima/ultima4/game/script.h"
30#include "ultima/ultima4/map/tile.h"
31#include "ultima/ultima4/core/types.h"
32
33namespace Ultima {
34namespace Ultima4 {
35
36class Armor;
37class Party;
38class Weapon;
39
40typedef Common::Array<class PartyMember *> PartyMemberVector;
41
42#define ALL_PLAYERS -1
43
44enum KarmaAction {
45 KA_FOUND_ITEM,
46 KA_STOLE_CHEST,
47 KA_GAVE_TO_BEGGAR,
48 KA_GAVE_ALL_TO_BEGGAR,
49 KA_BRAGGED,
50 KA_HUMBLE,
51 KA_HAWKWIND,
52 KA_MEDITATION,
53 KA_BAD_MANTRA,
54 KA_ATTACKED_GOOD,
55 KA_FLED_EVIL,
56 KA_FLED_GOOD,
57 KA_HEALTHY_FLED_EVIL,
58 KA_KILLED_EVIL,
59 KA_SPARED_GOOD,
60 KA_DONATED_BLOOD,
61 KA_DIDNT_DONATE_BLOOD,
62 KA_CHEAT_REAGENTS,
63 KA_DIDNT_CHEAT_REAGENTS,
64 KA_USED_SKULL,
65 KA_DESTROYED_SKULL
66};
67
68enum HealType {
69 HT_NONE,
70 HT_CURE,
71 HT_FULLHEAL,
72 HT_RESURRECT,
73 HT_HEAL,
74 HT_CAMPHEAL,
75 HT_INNHEAL
76};
77
78enum InventoryItem {
79 INV_NONE,
80 INV_WEAPON,
81 INV_ARMOR,
82 INV_FOOD,
83 INV_REAGENT,
84 INV_GUILDITEM,
85 INV_HORSE
86};
87
88enum CannotJoinError {
89 JOIN_SUCCEEDED,
90 JOIN_NOT_EXPERIENCED,
91 JOIN_NOT_VIRTUOUS
92};
93
94enum EquipError {
95 EQUIP_SUCCEEDED,
96 EQUIP_NONE_LEFT,
97 EQUIP_CLASS_RESTRICTED
98};
99
103class PartyMember : public Creature, public Script::Provider {
104public:
106 virtual ~PartyMember();
107
112
117
118 // Accessor methods
119 int getHp() const override;
120 int getMaxHp() const {
121 return _player->_hpMax;
122 }
123 int getExp() const {
124 return _player->_xp;
125 }
126 int getStr() const {
127 return _player->_str;
128 }
129 int getDex() const {
130 return _player->_dex;
131 }
132 int getInt() const {
133 return _player->_intel;
134 }
135 int getMp() const {
136 return _player->_mp;
137 }
138
143 int getMaxMp() const;
144
145 const Weapon *getWeapon() const;
146 const Armor *getArmor() const;
147 Common::String getName() const override;
148 SexType getSex() const;
149 ClassType getClass() const;
150 CreatureStatus getState() const override;
151
155 int getRealLevel() const;
156
161 int getMaxLevel() const;
162
166 void addStatus(StatusType status) override;
167
171 void adjustMp(int pts);
172
177
181 void applyEffect(TileEffect effect);
182
186 void awardXp(int xp);
187
191 bool heal(HealType type);
192
196 void removeStatus(StatusType status) override;
197
198 void setHp(int hp) override;
199 void setMp(int mp);
200 EquipError setArmor(const Armor *a);
201 EquipError setWeapon(const Weapon *w);
202
211 bool applyDamage(int damage, bool byplayer = false) override;
212 int getAttackBonus() const override;
213 int getDefense() const override;
214 bool dealDamage(Creature *m, int damage) override;
215
220
225 const Common::String &getHitTile() const override;
226
231 const Common::String &getMissTile() const override;
232 bool isDead();
233 bool isDisabled();
234
241
245 void putToSleep() override;
246
250 void wakeUp() override;
251
252protected:
253 static MapTile tileForClass(int klass);
254
255 SaveGamePlayerRecord *_player;
256 class Party *_party;
257};
258
263public:
264 enum Type {
265 GENERIC,
266 LOST_EIGHTH,
267 ADVANCED_LEVEL,
268 STARVING,
269 TRANSPORT_CHANGED,
270 PLAYER_KILLED,
271 ACTIVE_PLAYER_CHANGED,
272 MEMBER_JOINED,
273 PARTY_REVIVED,
274 INVENTORY_ADDED
275 };
276
277 PartyEvent(Type type, PartyMember *partyMember) : _type(type), _player(partyMember) { }
278
279 Type _type;
280 PartyMember *_player;
281};
282
284
285class Party : public Observable<Party *, PartyEvent &>, public Script::Provider {
286 friend class PartyMember;
287public:
288 Party(SaveGame *saveGame);
289 virtual ~Party();
290
294 void notifyOfChange(PartyMember *partyMember = 0, PartyEvent::Type = PartyEvent::GENERIC);
295
296 // Used to translate script values into something useful
297 Common::String translate(Common::Array<Common::String> &parts) override;
298
299 void adjustFood(int food);
300 void adjustGold(int gold);
301
307 void adjustKarma(KarmaAction action);
308
312 void applyEffect(TileEffect effect);
313
317 bool attemptElevation(Virtue virtue);
318
322 void burnTorch(int turns = 1);
323
327 bool canEnterShrine(Virtue virtue);
328
332 bool canPersonJoin(Common::String name, Virtue *v);
333
337 void damageShip(uint pts);
338
343 bool donate(int quantity);
344
348 void endTurn();
349
353 int getChest();
354
358 int getTorchDuration() const;
359
363 void healShip(uint pts);
364
368 bool isFlying() const;
369
374
378 bool isDead();
379
385
390 CannotJoinError join(Common::String name);
391
395 bool lightTorch(int duration = 100, bool loseTorch = true);
396
401
406 MapTile getTransport() const;
407 void setTransport(MapTile transport);
408 void setShipHull(int str);
409
410 Direction getDirection() const;
411 void setDirection(Direction dir);
412
413 void adjustReagent(int reagent, int amt);
414 int getReagent(int reagent) const;
415 short *getReagentPtr(int reagent) const;
416
417 void setActivePlayer(int p);
418 int getActivePlayer() const;
419
420 void swapPlayers(int p1, int p2);
421
425 int size() const;
426
430 PartyMember *member(int index) const;
431
432private:
433 void syncMembers();
434 PartyMemberVector _members;
435 SaveGame *_saveGame;
436 MapTile _transport;
437 int _torchDuration;
438 int _activePlayer;
439#ifdef IOS_ULTIMA4
440 friend void U4IOS::syncPartyMembersWithSaveGame();
441#endif
442};
443
444bool isPartyMember(Object *punknown);
445
446} // End of namespace Ultima4
447} // End of namespace Ultima
448
449#endif
Definition: str.h:59
Definition: armor.h:34
Definition: creature.h:159
Definition: map_tile.h:34
Definition: object.h:43
Definition: observable.h:45
Definition: player.h:262
Definition: player.h:285
bool isPersonJoined(Common::String name)
bool attemptElevation(Virtue virtue)
bool canPersonJoin(Common::String name, Virtue *v)
void notifyOfChange(PartyMember *partyMember=0, PartyEvent::Type=PartyEvent::GENERIC)
bool lightTorch(int duration=100, bool loseTorch=true)
bool donate(int quantity)
void adjustKarma(KarmaAction action)
bool canEnterShrine(Virtue virtue)
void healShip(uint pts)
void damageShip(uint pts)
void applyEffect(TileEffect effect)
PartyMember * member(int index) const
CannotJoinError join(Common::String name)
int getTorchDuration() const
void burnTorch(int turns=1)
Definition: player.h:103
const Common::String & getMissTile() const override
bool applyDamage(int damage, bool byplayer=false) override
void removeStatus(StatusType status) override
void applyEffect(TileEffect effect)
void addStatus(StatusType status) override
Common::String translate(Common::Array< Common::String > &parts) override
const Common::String & getHitTile() const override
bool heal(HealType type)
Definition: script.h:55
Definition: weapon.h:33
Definition: savegame.h:270
Definition: savegame.h:193