monstinf.h

Go to the documentation of this file.
00001 
00007 #ifndef INCL_MONSTINF
00008 #define INCL_MONSTINF 1
00009 
00010 /*
00011 Copyright (C) 2000-2001 The Exult Team
00012 
00013 This program is free software; you can redistribute it and/or
00014 modify it under the terms of the GNU General Public License
00015 as published by the Free Software Foundation; either version 2
00016 of the License, or (at your option) any later version.
00017 
00018 This program is distributed in the hope that it will be useful,
00019 but WITHOUT ANY WARRANTY; without even the implied warranty of
00020 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00021 GNU General Public License for more details.
00022 
00023 You should have received a copy of the GNU General Public License
00024 along with this program; if not, write to the Free Software
00025 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00026 */
00027 
00028 #ifndef ALPHA_LINUX_CXX
00029 #  include <iosfwd>
00030 #endif
00031 
00032 #include <cassert>
00033 
00034 /*
00035  *  An element from 'equip.dat', describing a monster's equipment:
00036  */
00037 class Equip_element
00038   {
00039   unsigned short shapenum;  // What to create, or 0 for nothing.
00040   unsigned char probability;  // 0-100:  probabilit of creation.
00041   unsigned char quantity;   // # to create.
00042 public:
00043   friend class Monster_info;
00044   friend class Monster_actor;
00045   Equip_element()
00046     {  }
00047   void set(int shnum, int prob, int quant)
00048     {
00049     shapenum = shnum;
00050     probability = prob;
00051     quantity = quant;
00052     }
00053   int get_shapenum() const
00054     { return shapenum; }
00055   int get_probability() const
00056     { return probability; }
00057   int get_quantity() const
00058     { return quantity; }
00059   };
00060 
00061 /*
00062  *  A record from 'equip.dat' consists of 10 elements.
00063  */
00064 class Equip_record
00065   {
00066   Equip_element elements[10];
00067 public:
00068   friend class Monster_info;
00069   friend class Monster_actor;
00070   Equip_record()
00071     {  }
00072           // Set i'th element.
00073   void set(int i, int shnum, int prob, int quant)
00074     { elements[i].set(shnum, prob, quant); }
00075   Equip_element& get(int i)
00076     { assert(i >= 0 && i < 10); return elements[i]; }
00077   };
00078 
00079 /*
00080  *  Monster info. from 'monsters.dat':
00081  */
00082 class Monster_info
00083   {
00084   static Equip_record *equip; // ->equipment info.
00085   static int equip_cnt;   // # entries in equip.
00086   static Monster_info default_info; // For shapes not found.
00087   unsigned char strength;   // Attributes.
00088   unsigned char dexterity;
00089   unsigned char intelligence;
00090   unsigned char alignment;  // Default alignment.
00091   unsigned char combat;
00092   unsigned char armor;    // These are unarmed stats.
00093   unsigned char weapon;
00094   unsigned char reach;
00095   unsigned char flags;    // Defined below.
00096           // The following are bits corresponding
00097           //   to Weapon_info::Damage_type.
00098   unsigned char vulnerable, immune;
00099   unsigned char equip_offset; // Offset in 'equip.dat' (1 based;
00100           //   if 0, there's none.)
00101   bool m_splits;      // For slimes.
00102   bool m_cant_die;
00103   bool m_cant_yell;   // Can't yell during combat.
00104   bool m_cant_bleed;
00105   bool m_poison_safe;   // Can't be poisoned.
00106 public:
00107   friend class Monster_actor;
00108   Monster_info() {  }
00109   int read(std::istream& mfile);  // Read in from file.
00110           // Write out.
00111   void write(int shapenum, std::ostream& mfile);
00112   static const Monster_info *get_default();
00113           // Done by Game_window:
00114   static void set_equip(Equip_record *eq, int cnt)
00115     {
00116     equip = eq;
00117     equip_cnt = cnt;
00118     }
00119   static int get_equip_cnt()
00120     { return equip_cnt; }
00121   static Equip_record& get_equip(int i)
00122     { assert(i >= 0 && i < equip_cnt); return equip[i]; }
00123   bool splits() const
00124     { return m_splits; }
00125   void set_splits(bool tf)
00126     { m_splits = tf; }
00127   bool cant_die() const
00128     { return m_cant_die; }
00129   void set_cant_die(bool tf)
00130     { m_cant_die = tf; }
00131   bool cant_yell() const
00132     { return m_cant_yell; }
00133   void set_cant_yell(bool tf)
00134     { m_cant_yell = tf; }
00135   bool cant_bleed() const
00136     { return m_cant_bleed; }
00137   void set_cant_bleed(bool tf)
00138     { m_cant_bleed = tf; }
00139   bool poison_safe() const
00140     { return m_poison_safe; }
00141   void set_poison_safe(bool tf)
00142     { m_poison_safe = tf; }
00143           // Get bits indicating
00144           //   Weapon_info::damage_type:
00145   unsigned char get_vulnerable() const
00146     { return vulnerable; }
00147   void set_vulnerable(unsigned char v)
00148     { vulnerable = v; }
00149   unsigned char get_immune() const
00150     { return immune; }
00151   void set_immune(unsigned char v)
00152     { immune = v; }
00153   enum Flags {
00154     fly = 0,
00155     swim = 1,
00156     walk = 2,
00157     ethereal = 3,   // Can walk through walls.
00158     no_body = 4   // Don't create body.
00159           // 5:  gazer, hook only.
00160 //Don't think so magic_only = 7,  // Can only be hurt by magic weapons.
00161           // 8:  bat only.
00162 //    slow = 9    // E.g., slime, corpser.
00163           // 10:  skeleton only.
00164     };
00165   unsigned char get_flags() const // Get above set of flags.
00166     { return flags; }
00167   void set_flags(unsigned char f)
00168     { flags = f; }
00169   bool has_no_body() const  // No dead body?
00170     { return (flags>>no_body)&1; }
00171   int get_strength() const  
00172     { return strength; }
00173   int get_dexterity() const
00174     { return dexterity; }
00175   int get_intelligence() const
00176     { return intelligence; }
00177   int get_alignment() const
00178     { return alignment; }
00179   void set_alignment(int a)
00180     { alignment = a; }
00181   int get_combat() const
00182     { return combat; }
00183   int get_armor() const
00184     { return armor; }
00185   int get_weapon() const
00186     { return weapon; }
00187   int get_reach() const
00188     { return reach; }
00189   void set_stats(int str, int dex, int intel, int cmb, int armour,
00190       int wpn, int rch);
00191   int get_equip_offset() const
00192     { return equip_offset; }
00193   void set_equip_offset(int o)
00194     { equip_offset = o; }
00195   };
00196 
00197 
00198 
00199 #endif

Generated on Mon Jul 9 14:42:50 2007 for ExultEngine by  doxygen 1.5.1