00001
00007 #ifndef INCL_SHAPEINF
00008 #define INCL_SHAPEINF 1
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028 class Monster_info;
00029
00030 #include <iosfwd>
00031
00032
00033
00034
00035
00036 class Weapon_info
00037 {
00038 char damage;
00039 public:
00040 enum Powers
00041 {
00042 sleep = 1,
00043 charm = 2,
00044 curse = 4,
00045 poison = 8,
00046 paralyze = 16,
00047 magebane = 32
00048 };
00049 enum Damage_type
00050
00051
00052 {
00053 normal_damage = 0,
00054 fire_damage = 1,
00055 magic_damage = 2,
00056 poison_damage = 3
00057 };
00058 enum Actor_frames
00059 {
00060 raise = 1,
00061 reach = 2
00062 };
00063 private:
00064 unsigned char powers;
00065 unsigned char damage_type;
00066 unsigned char actor_frames;
00067
00068
00069
00070 short ammo;
00071
00072
00073
00074 short projectile;
00075 bool m_explodes;
00076 bool m_returns;
00077 bool m_no_blocking;
00078 short usecode;
00079 unsigned char uses;
00080
00081 unsigned char range;
00082 short sfx, hitsfx;
00083 public:
00084 friend class Shape_info;
00085 Weapon_info() { }
00086 int read(std::istream& mfile, bool bg);
00087
00088 void write(int shapenum, std::ostream& mfile, bool bg);
00089 int get_damage() const
00090 { return damage; }
00091 int get_damage_type() const
00092 { return damage_type; }
00093 void set_damage(int dmg, int dmgtype)
00094 { damage = dmg; damage_type = dmgtype; }
00095 unsigned char get_powers() const
00096 { return powers; }
00097 void set_powers(unsigned char p)
00098 { powers = p; }
00099 unsigned char get_actor_frames(bool projectile) const
00100 { return !projectile ? (actor_frames&3) : (actor_frames>>2); }
00101 void set_actor_frames(unsigned char f)
00102 { actor_frames = f; }
00103 int get_ammo_consumed()
00104 { return ammo > 0 ? ammo : 0; }
00105 void set_ammo(int a)
00106 { ammo = a; }
00107 bool uses_charges()
00108 { return ammo == -2; }
00109 bool is_thrown() const
00110 { return uses == 1 || uses == 2 || m_returns; }
00111 bool returns() const
00112 { return m_returns; }
00113 void set_returns(bool tf)
00114 { m_returns = tf; }
00115 bool explodes() const
00116 { return m_explodes; }
00117 void set_explodes(bool tf)
00118 { m_explodes = tf; }
00119 bool no_blocking() const
00120 { return m_no_blocking; }
00121 void set_no_blocking(bool tf)
00122 { m_no_blocking = tf; }
00123 unsigned char get_uses() const
00124 { return uses; }
00125 void set_uses(unsigned char u)
00126 { uses = u; }
00127 int get_range()
00128 { return range; }
00129 void set_range(int r)
00130 { range = r; }
00131 int get_striking_range()
00132 { return uses < 3 ? range/2 : 0; }
00133 int get_projectile_range()
00134 { return uses == 3 ? range : is_thrown() ? 20 : 0; }
00135 int get_projectile()
00136 { return projectile; }
00137 void set_projectile(int p)
00138 { projectile = p; }
00139 int get_usecode()
00140 { return usecode; }
00141 void set_usecode(int u)
00142 { usecode = u; }
00143 int get_sfx()
00144 { return sfx; }
00145 int get_hitsfx()
00146 { return hitsfx; }
00147 void set_sfxs(int s, int hits)
00148 { sfx = s; hitsfx = hits; }
00149 };
00150
00151
00152
00153
00154 class Ammo_info
00155 {
00156 int family_shape;
00157 unsigned short type2;
00158 unsigned char damage;
00159 unsigned char powers;
00160 unsigned char damage_type;
00161 bool m_no_blocking;
00162 public:
00163 friend class Shapes_vga_file;
00164 Ammo_info()
00165 { }
00166 int read(std::istream& mfile);
00167
00168 void write(int shapenum, std::ostream& mfile);
00169 int get_family_shape()
00170 { return family_shape; }
00171 void set_family_shape(int f)
00172 { family_shape = f; }
00173 int get_damage()
00174 { return damage; }
00175 int get_damage_type() const
00176 { return damage_type; }
00177 void set_damage(int dmg, int dtype)
00178 { damage = dmg; damage_type = dtype; }
00179 unsigned char get_powers() const
00180 { return powers; }
00181 void set_powers(unsigned char p)
00182 { powers = p; }
00183 bool no_blocking() const
00184 { return m_no_blocking; }
00185 void set_no_blocking(bool tf)
00186 { m_no_blocking = tf; }
00187 };
00188
00189
00190
00191
00192 class Armor_info
00193 {
00194 unsigned char prot;
00195 unsigned char immune;
00196 public:
00197 friend class Shape_info;
00198 Armor_info() { }
00199 int read(std::istream& mfile);
00200
00201 void write(int shapenum, std::ostream& mfile);
00202 unsigned char get_prot() const
00203 { return prot; }
00204 void set_prot(unsigned char p)
00205 { prot = p; }
00206 unsigned char get_immune() const
00207 { return immune; }
00208 void set_immune(unsigned char i)
00209 { immune = i; }
00210 };
00211
00212
00213
00214
00215 class Shape_info
00216 {
00217 unsigned char tfa[3];
00218
00219
00220 unsigned char dims[3];
00221 unsigned char weight, volume;
00222 unsigned char shpdims[2];
00223 unsigned char ready_type;
00224
00225 bool occludes_flag;
00226 unsigned char *weapon_offsets;
00227
00228 Armor_info *armor;
00229 Weapon_info *weapon;
00230 Ammo_info *ammo;
00231 Monster_info *monstinf;
00232 void set_tfa_data()
00233 {
00234 dims[0] = 1 + (tfa[2]&7);
00235 dims[1] = 1 + ((tfa[2]>>3)&7);
00236 dims[2] = (tfa[0] >> 5);
00237 }
00238
00239 void set_tfa(int i, int bit, bool tf)
00240 { tfa[i] = tf ? (tfa[i]|(1<<bit)) : (tfa[i]&~(1<<bit)); }
00241
00242
00243 Shape_info(const Shape_info & other);
00244 const Shape_info & operator = (const Shape_info & other);
00245 public:
00246 friend class Shapes_vga_file;
00247 Shape_info() : weight(0), volume(0),
00248 ready_type(255), occludes_flag(false), weapon_offsets(0),
00249 armor(0), weapon(0), ammo(0), monstinf(0)
00250 {
00251 tfa[0] = tfa[1] = tfa[2] = shpdims[0] = shpdims[1] = 0;
00252 dims[0] = dims[1] = dims[2] = 0;
00253 }
00254 virtual ~Shape_info();
00255 int get_weight()
00256 { return weight; }
00257 int get_volume()
00258 { return volume; }
00259 void set_weight_volume(int w, int v)
00260 { weight = w; volume = v; }
00261 int get_armor()
00262 { return armor ? armor->prot : 0; }
00263 Weapon_info *get_weapon_info()
00264 { return weapon; }
00265 Weapon_info *set_weapon_info(bool tf);
00266 Ammo_info *get_ammo_info()
00267 { return ammo; }
00268 Ammo_info *set_ammo_info(bool tf);
00269 Armor_info *get_armor_info()
00270 { return armor; }
00271 Armor_info *set_armor_info(bool tf);
00272 Monster_info *get_monster_info()
00273 { return monstinf; }
00274 Monster_info *set_monster_info(bool tf);
00275
00276
00277 int get_3d_xtiles(unsigned int framenum = 0)
00278 { return dims[(framenum >> 5)&1]; }
00279 int get_3d_ytiles(unsigned int framenum = 0)
00280 { return dims[1 ^ ((framenum >> 5)&1)]; }
00281 int get_3d_height()
00282 { return dims[2]; }
00283 void set_3d(int xt, int yt, int zt);
00284 unsigned char get_tfa(int i)
00285 { return tfa[i]; }
00286 int has_sfx()
00287 { return (tfa[0] & (1<<0)) != 0; }
00288 void set_sfx(bool tf)
00289 { set_tfa(0, 0, tf); }
00290 int has_strange_movement()
00291 { return (tfa[0] & (1<<1)) != 0; }
00292 void set_strange_movement(bool tf)
00293 { set_tfa(0, 1, tf); }
00294 int is_animated()
00295 { return (tfa[0] & (1<<2)) != 0; }
00296 void set_animated(bool tf)
00297 { set_tfa(0, 2, tf); }
00298 int is_solid()
00299 { return (tfa[0] & (1<<3)) != 0; }
00300 void set_solid(bool tf)
00301 { set_tfa(0, 3, tf); }
00302 int is_water()
00303 { return (tfa[0] & (1<<4)) != 0; }
00304 void set_water(bool tf)
00305 { set_tfa(0, 4, tf); }
00306 int is_poisonous()
00307 { return (tfa[1] & (1<<4)) != 0; }
00308 int is_field()
00309 { return (tfa[1] & (1<<4)) != 0; }
00310 void set_field(bool tf)
00311 { set_tfa(1, 4, tf); }
00312 int is_door()
00313 { return (tfa[1] & (1<<5)) != 0; }
00314 void set_door(bool tf)
00315 { set_tfa(1, 5, tf); }
00316 int is_barge_part()
00317 { return (tfa[1] & (1<<6)) != 0; }
00318 void set_barge_part(bool tf)
00319 { set_tfa(1, 6, tf); }
00320 int is_transparent()
00321 { return (tfa[1] & (1<<7)) != 0; }
00322 void set_transparent(bool tf)
00323 { set_tfa(1, 7, tf); }
00324 int is_light_source()
00325 { return (tfa[2] & (1<<6)) != 0; }
00326 void set_light_source(bool tf)
00327 { set_tfa(2, 6, tf); }
00328 int has_translucency()
00329 { return (tfa[2] & (1<<7)) != 0; }
00330 void set_translucency(bool tf)
00331 { set_tfa(2, 7, tf); }
00332 int is_xobstacle()
00333 { return (shpdims[1] & 1) != 0; }
00334 int is_yobstacle()
00335 { return (shpdims[0] & 1) != 0; }
00336 void set_obstacle(bool x, bool y)
00337 {
00338 shpdims[1] = x ? (shpdims[1]|1) : (shpdims[1]&~1);
00339 shpdims[0] = y ? (shpdims[0]|1) : (shpdims[0]&~1);
00340 }
00341
00342
00343
00344 enum Shape_class {
00345 unusable = 0,
00346 quality = 2,
00347 quantity = 3,
00348 has_hp = 4,
00349 quality_flags = 5,
00350
00351 container = 6,
00352 hatchable = 7,
00353 spellbook = 8,
00354 barge = 9,
00355 virtue_stone = 11,
00356 monster = 12,
00357 human = 13,
00358 building = 14
00359 };
00360 Shape_class get_shape_class()
00361 { return (Shape_class) (tfa[1]&15); }
00362 void set_shape_class(Shape_class c)
00363 { tfa[1] = (tfa[1]&~15)|(int) c; }
00364 bool is_npc()
00365 {
00366 Shape_class c = get_shape_class();
00367 return c == human || c == monster;
00368 }
00369 bool has_quantity()
00370 { return get_shape_class() == quantity; }
00371 bool has_quality_flags()
00372 { return get_shape_class() == quality_flags; }
00373 bool has_quality()
00374 {
00375 #if 0
00376 static bool qual[16] =
00377
00378 { false, false, true, false, false, false,
00379
00380 true, true, false, false, false, true,
00381
00382 true, true, false, false };
00383 #endif
00384 Shape_class c = get_shape_class();
00385 return (c == 2 || c == 6 || c == 7 || c == 11 || c == 12 || c == 13);
00386
00387 }
00388 bool occludes() const
00389 { return occludes_flag; }
00390 void set_occludes(bool tf)
00391 { occludes_flag = tf; }
00392 unsigned char get_ready_type()
00393 { return ready_type; }
00394 void set_ready_type(unsigned char t)
00395 { ready_type = t; }
00396
00397 void get_weapon_offset(int frame, unsigned char& x, unsigned char& y)
00398 {
00399 if(!weapon_offsets)
00400 x = 255;
00401 else
00402 {
00403
00404 x = weapon_offsets[frame * 2];
00405 y = weapon_offsets[frame * 2 + 1];
00406 }
00407 }
00408 void set_weapon_offset(int frame, unsigned char x, unsigned char y);
00409 };
00410
00411 #endif