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