ScummVM API documentation
shape_info.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 ULTIMA8_GFX_SHAPEINFO_H
23#define ULTIMA8_GFX_SHAPEINFO_H
24
25#include "ultima/ultima8/world/weapon_info.h"
26#include "ultima/ultima8/world/armour_info.h"
27#include "ultima/ultima8/world/damage_info.h"
28#include "ultima/ultima8/world/actors/monster_info.h"
29
30namespace Ultima {
31namespace Ultima8 {
32
33class ShapeInfo {
34public:
35 enum SFlags {
36 SI_FIXED = 0x0001,
37 SI_SOLID = 0x0002,
38 SI_SEA = 0x0004,
39 SI_LAND = 0x0008,
40 SI_OCCL = 0x0010,
41 SI_BAG = 0x0020,
42 SI_DAMAGING = 0x0040,
43 SI_NOISY = 0x0080,
44 SI_DRAW = 0x0100,
45 SI_IGNORE = 0x0200,
46 SI_ROOF = 0x0400, // reflective in Crusader?
47 SI_TRANSL = 0x0800,
48 SI_EDITOR = 0x1000,
49 // Note: overlapping names for the rest of the bits depending on U8 or Cru.
50 SI_U8_EXPLODE = 0x2000,
51 SI_CRU_SELECTABLE = 0x2000,
52 SI_UNKNOWN46 = 0x4000,
53 SI_CRU_PRELOAD = 0x4000, // we don't need this flag, we preload everything.
54 SI_UNKNOWN47 = 0x8000,
55 SI_CRU_SOUND = 0x8000, // TODO: how is this used?
56 SI_CRU_TARGETABLE = 0x10000,
57 SI_CRU_NPC = 0x20000,
58 SI_CRU_UNK66 = 0x40000,
59 SI_CRU_UNK67 = 0x80000
60 };
61
62 enum SFamily {
63 SF_GENERIC = 0,
64 SF_QUALITY = 1,
65 SF_QUANTITY = 2,
66 SF_GLOBEGG = 3,
67 // "Unk" eggs are not "unknown", they are triggers for usecode
68 // (unk is the source language for usecode)
69 SF_UNKEGG = 4,
70 SF_BREAKABLE = 5,
71 SF_CONTAINER = 6,
72 SF_MONSTEREGG = 7,
73 SF_TELEPORTEGG = 8,
74 SF_REAGENT = 9,
75 SF_CRUWEAPON = 10, // Used in Crusader
76 SF_CRUAMMO = 11, // Used in Crusader
77 SF_CRUBOMB = 12, // Used in Crusader
78 SF_CRUINVITEM = 13, // Used in Crusader
79 SF_15 = 15
80 };
81
82 enum SEquipType {
83 SE_NONE = 0,
84 SE_SHIELD = 1,
85 SE_ARM = 2,
86 SE_HEAD = 3,
87 SE_BODY = 4,
88 SE_LEGS = 5,
89 SE_WEAPON = 6,
90 SE_BACKPACK = 7
91 };
92
93 uint32 _flags;
94 uint32 _x, _y, _z;
95 uint32 _family;
96 uint32 _equipType;
97 uint32 _animType, _animData, _animSpeed;
98 uint32 _weight, _volume;
99
100 WeaponInfo *_weaponInfo;
101 ArmourInfo *_armourInfo;
102 MonsterInfo *_monsterInfo;
103 DamageInfo *_damageInfo;
104
105 inline bool is_fixed() const {
106 return (_flags & SI_FIXED) != 0;
107 }
108 inline bool is_solid() const {
109 return (_flags & SI_SOLID) != 0;
110 }
111 inline bool is_sea() const {
112 return (_flags & SI_SEA) != 0;
113 }
114 inline bool is_land() const {
115 return (_flags & SI_LAND) != 0;
116 }
117 inline bool is_occl() const {
118 return (_flags & SI_OCCL) != 0;
119 }
120 inline bool is_bag() const {
121 return (_flags & SI_BAG) != 0;
122 }
123 inline bool is_damaging() const {
124 return (_flags & SI_DAMAGING) != 0;
125 }
126 inline bool is_noisy() const {
127 return (_flags & SI_NOISY) != 0;
128 }
129 inline bool is_draw() const {
130 return (_flags & SI_DRAW) != 0;
131 }
132 inline bool is_ignore() const {
133 return (_flags & SI_IGNORE) != 0;
134 }
135 inline bool is_roof() const {
136 return (_flags & SI_ROOF) != 0;
137 }
138 inline bool is_translucent() const {
139 return (_flags & SI_TRANSL) != 0;
140 }
141 inline bool is_editor() const {
142 return (_flags & SI_EDITOR) != 0;
143 }
144 inline bool is_u8_explode() const {
145 return (_flags & SI_U8_EXPLODE) != 0;
146 }
147 inline bool is_targetable() const {
148 return (_flags & (SI_OCCL | SI_CRU_TARGETABLE));
149 }
150 inline bool is_invitem() const {
151 return (_family == SF_CRUINVITEM);
152 }
153
154 bool hasQuantity() const {
155 return (_family == SF_QUANTITY || _family == SF_REAGENT);
156 }
157
158 bool takesDamage() const {
159 return (_damageInfo && _damageInfo->takesDamage());
160 }
161
162 bool getTypeFlag(int typeFlag) const;
163 bool getTypeFlagU8(int typeFlag) const;
164 bool getTypeFlagCrusader(int typeFlag) const;
165
166 inline void getFootpadWorld(int32 &x, int32 &y, int32 &z, uint16 flipped) const;
167
168 ShapeInfo() :
169 _flags(0), _x(0), _y(0), _z(0),
170 _family(0), _equipType(0), _animType(0), _animData(0),
171 _animSpeed(0), _weight(0), _volume(0),
172 _weaponInfo(nullptr), _armourInfo(nullptr),
173 _monsterInfo(nullptr), _damageInfo(nullptr) { }
174
175 ~ShapeInfo() {
176 delete _weaponInfo;
177 delete[] _armourInfo;
178 delete _monsterInfo;
179 delete _damageInfo;
180 }
181
182};
183
184inline void ShapeInfo::getFootpadWorld(int32 &x, int32 &y, int32 &z, uint16 flipped) const {
185 z = _z * 8;
186
187 if (flipped) {
188 x = _y * 32;
189 y = _x * 32;
190 } else {
191 x = _x * 32;
192 y = _y * 32;
193 }
194}
195
196} // End of namespace Ultima8
197} // End of namespace Ultima
198
199#endif
Definition: damage_info.h:35
Definition: shape_info.h:33
Definition: armour_info.h:28
Definition: monster_info.h:30
Definition: weapon_info.h:30