ScummVM API documentation
weapon.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_WEAPON_H
23#define ULTIMA4_GAME_WEAPON_H
24
25#include "ultima/ultima4/filesys/savegame.h"
26
27namespace Ultima {
28namespace Ultima4 {
29
30class ConfigElement;
31class Weapons;
32
33class Weapon {
34 friend class Weapons;
35public:
37 enum Flags {
38 WEAP_LOSE = 0x0001,
41 WEAP_ALWAYSHITS = 0x0008,
42 WEAP_MAGIC = 0x0010,
45 WEAP_RETURNS = 0x0100,
46 WEAP_DONTSHOWTRAVEL = 0x0200
47 };
48
49public:
50 WeaponType getType() const {
51 return _type;
52 }
53 const Common::String &getName() const {
54 return _name;
55 }
56 const Common::String &getAbbrev() const {
57 return _abbr;
58 }
59 bool canReady(ClassType klass) const {
60 return (_canUse & (1 << klass)) != 0;
61 }
62 int getRange() const {
63 return _range;
64 }
65 int getDamage() const {
66 return _damage;
67 }
68 const Common::String &getHitTile() const {
69 return _hitTile;
70 }
71 const Common::String &getMissTile() const {
72 return _missTile;
73 }
74 const Common::String &leavesTile() const {
75 return _leaveTile;
76 }
77 unsigned short getFlags() const {
78 return _flags;
79 }
80
81 bool loseWhenUsed() const {
82 return _flags & WEAP_LOSE;
83 }
84 bool loseWhenRanged() const {
85 return _flags & WEAP_LOSEWHENRANGED;
86 }
87 bool canChooseDistance() const {
88 return _flags & WEAP_CHOOSEDISTANCE;
89 }
90 bool alwaysHits() const {
91 return _flags & WEAP_ALWAYSHITS;
92 }
93 bool isMagic() const {
94 return _flags & WEAP_MAGIC;
95 }
96 bool canAttackThroughObjects() const {
97 return _flags & WEAP_ATTACKTHROUGHOBJECTS;
98 }
99 bool rangeAbsolute() const {
100 return _flags & WEAP_ABSOLUTERANGE;
101 }
102 bool returns() const {
103 return _flags & WEAP_RETURNS;
104 }
105 bool showTravel() const {
106 return !(_flags & WEAP_DONTSHOWTRAVEL);
107 }
108
109private:
110 Weapon(WeaponType weaponType, const ConfigElement &conf);
111
112 WeaponType _type;
113 Common::String _name;
114 Common::String _abbr;
115 byte _canUse;
116 int _range;
117 int _damage;
118 Common::String _hitTile;
119 Common::String _missTile;
120 Common::String _leaveTile;
121 unsigned short _flags;
122};
123
124class Weapons : public Common::Array<Weapon *> {
125private:
126 bool _confLoaded;
127
128 void loadConf();
129public:
134
139
143 const Weapon *get(WeaponType w);
144
148 const Weapon *get(const Common::String &name);
149};
150
151extern Weapons *g_weapons;
152
153} // End of namespace Ultima4
154} // End of namespace Ultima
155
156#endif
Definition: array.h:52
Definition: str.h:59
Definition: weapon.h:33
Flags
Definition: weapon.h:37
@ WEAP_LOSEWHENRANGED
Definition: weapon.h:39
@ WEAP_ALWAYSHITS
Definition: weapon.h:41
@ WEAP_ABSOLUTERANGE
Definition: weapon.h:44
@ WEAP_DONTSHOWTRAVEL
Definition: weapon.h:46
@ WEAP_ATTACKTHROUGHOBJECTS
Definition: weapon.h:43
@ WEAP_LOSE
Definition: weapon.h:38
@ WEAP_CHOOSEDISTANCE
Definition: weapon.h:40
@ WEAP_MAGIC
Definition: weapon.h:42
@ WEAP_RETURNS
Definition: weapon.h:45
Definition: weapon.h:124
const Weapon * get(const Common::String &name)
const Weapon * get(WeaponType w)