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
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation; either version 2
10  * of the License, or (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, write to the Free Software
19  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20  *
21  */
22 
23 #ifndef ULTIMA8_GRAPHICS_SHAPEINFO_H
24 #define ULTIMA8_GRAPHICS_SHAPEINFO_H
25 
26 #include "ultima/ultima8/world/weapon_info.h"
27 #include "ultima/ultima8/world/armour_info.h"
28 #include "ultima/ultima8/world/damage_info.h"
29 #include "ultima/ultima8/world/actors/monster_info.h"
30 
31 namespace Ultima {
32 namespace Ultima8 {
33 
34 class ShapeInfo {
35 public:
36 	enum SFlags {
37 		SI_FIXED   = 0x0001,
38 		SI_SOLID   = 0x0002,
39 		SI_SEA     = 0x0004,
40 		SI_LAND    = 0x0008,
41 		SI_OCCL    = 0x0010,
42 		SI_BAG     = 0x0020,
43 		SI_DAMAGING = 0x0040,
44 		SI_NOISY   = 0x0080,
45 		SI_DRAW    = 0x0100,
46 		SI_IGNORE  = 0x0200,
47 		SI_ROOF    = 0x0400, // reflective in Crusader?
48 		SI_TRANSL  = 0x0800,
49 		SI_EDITOR  = 0x1000,
50 		// Note: overlapping names for the rest of the bits depending on U8 or Cru.
51 		SI_U8_EXPLODE  = 0x2000,
52 		SI_CRU_SELECTABLE = 0x2000,
53 		SI_UNKNOWN46      = 0x4000,
54 		SI_CRU_PRELOAD    = 0x4000, // we don't need this flag, we preload everything.
55 		SI_UNKNOWN47      = 0x8000,
56 		SI_CRU_SOUND      = 0x8000, // TODO: how is this used?
57 		SI_CRU_TARGETABLE = 0x10000,
58 		SI_CRU_NPC        = 0x20000,
59 		SI_CRU_UNK66      = 0x40000,
60 		SI_CRU_UNK67      = 0x80000
61 	};
62 
63 	enum SFamily {
64 		SF_GENERIC     = 0,
65 		SF_QUALITY     = 1,
66 		SF_QUANTITY    = 2,
67 		SF_GLOBEGG     = 3,
68 		// "Unk" eggs are not "unknown", they are triggers for usecode
69 		// (unk is the source language for usecode)
70 		SF_UNKEGG      = 4,
71 		SF_BREAKABLE   = 5,
72 		SF_CONTAINER   = 6,
73 		SF_MONSTEREGG  = 7,
74 		SF_TELEPORTEGG = 8,
75 		SF_REAGENT     = 9,
76 		SF_CRUWEAPON   = 10, // Used in Crusader
77 		SF_CRUAMMO     = 11, // Used in Crusader
78 		SF_CRUBOMB     = 12, // Used in Crusader
79 		SF_CRUINVITEM  = 13, // Used in Crusader
80 		SF_15          = 15
81 	};
82 
83 	enum SEquipType {
84 		SE_NONE   = 0,
85 		SE_SHIELD = 1,
86 		SE_ARM    = 2,
87 		SE_HEAD   = 3,
88 		SE_BODY   = 4,
89 		SE_LEGS   = 5,
90 		SE_WEAPON = 6
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 
is_fixed()105 	inline bool is_fixed() const {
106 		return (_flags & SI_FIXED) != 0;
107 	}
is_solid()108 	inline bool is_solid() const {
109 		return (_flags & SI_SOLID) != 0;
110 	}
is_sea()111 	inline bool is_sea() const {
112 		return (_flags & SI_SEA) != 0;
113 	}
is_land()114 	inline bool is_land() const {
115 		return (_flags & SI_LAND) != 0;
116 	}
is_occl()117 	inline bool is_occl() const {
118 		return (_flags & SI_OCCL) != 0;
119 	}
is_bag()120 	inline bool is_bag() const {
121 		return (_flags & SI_BAG) != 0;
122 	}
is_damaging()123 	inline bool is_damaging() const {
124 		return (_flags & SI_DAMAGING) != 0;
125 	}
is_noisy()126 	inline bool is_noisy() const {
127 		return (_flags & SI_NOISY) != 0;
128 	}
is_draw()129 	inline bool is_draw() const {
130 		return (_flags & SI_DRAW) != 0;
131 	}
is_ignore()132 	inline bool is_ignore() const {
133 		return (_flags & SI_IGNORE) != 0;
134 	}
is_roof()135 	inline bool is_roof() const {
136 		return (_flags & SI_ROOF) != 0;
137 	}
is_translucent()138 	inline bool is_translucent() const {
139 		return (_flags & SI_TRANSL) != 0;
140 	}
is_editor()141 	inline bool is_editor() const {
142 		return (_flags & SI_EDITOR) != 0;
143 	}
is_u8_explode()144 	inline bool is_u8_explode() const {
145 		return (_flags & SI_U8_EXPLODE) != 0;
146 	}
is_targetable()147 	inline bool is_targetable() const {
148 		return (_flags & (SI_OCCL | SI_CRU_TARGETABLE));
149 	}
is_invitem()150 	inline bool is_invitem() const {
151 		return (_family == SF_CRUINVITEM);
152 	}
153 
hasQuantity()154 	bool hasQuantity() const {
155 		return (_family == SF_QUANTITY || _family == SF_REAGENT);
156 	}
157 
takesDamage()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 
ShapeInfo()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 
~ShapeInfo()175 	~ShapeInfo() {
176 		delete _weaponInfo;
177 		delete[] _armourInfo;
178 		delete _monsterInfo;
179 		delete _damageInfo;
180 	}
181 
182 };
183 
getFootpadWorld(int32 & x,int32 & y,int32 & z,uint16 flipped)184 inline 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
200