monstinf.cc

Go to the documentation of this file.
00001 
00007 /*
00008 Copyright (C) 2000-2001 The Exult Team
00009 
00010 This program is free software; you can redistribute it and/or
00011 modify it under the terms of the GNU General Public License
00012 as published by the Free Software Foundation; either version 2
00013 of the License, or (at your option) any later version.
00014 
00015 This program is distributed in the hope that it will be useful,
00016 but WITHOUT ANY WARRANTY; without even the implied warranty of
00017 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00018 GNU General Public License for more details.
00019 
00020 You should have received a copy of the GNU General Public License
00021 along with this program; if not, write to the Free Software
00022 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00023 */
00024 
00025 #ifdef HAVE_CONFIG_H
00026 #  include <config.h>
00027 #endif
00028 
00029 #include "utils.h"
00030 #include "monstinf.h"
00031 
00032 // #include "items.h"
00033 
00034 using std::ios;
00035 using std::cout;
00036 using std::endl;
00037 using std::istream;
00038 
00039 Equip_record *Monster_info::equip = 0;
00040 int Monster_info::equip_cnt = 0;
00041 Monster_info Monster_info::default_info;
00042 
00043 /*
00044  *  Read in monster info. from 'monsters.dat'.
00045  *
00046  *  Output: Shape # this entry describes.
00047  */
00048 
00049 int Monster_info::read
00050   (
00051   istream& in     // Read from here.
00052   )
00053   {
00054   uint8 buf[25];    // Entry length.
00055   in.read((char *) buf, sizeof(buf));
00056   uint8 *ptr = buf;
00057   int shapenum = Read2(ptr);  // Bytes 0-1.
00058   strength = (*ptr++ >> 2) & 63;  // Byte 2.
00059   dexterity = (*ptr++ >> 2) & 63; // Byte 3.
00060   m_poison_safe = (*ptr&1) != 0;  // This looks reasonable, as it
00061           //   includes automaton, slug, spider.
00062 //  if (poison_safe)
00063 //    cout << "Shape " << item_names[shapenum] << " is poison_safe"<< endl;
00064   intelligence = (*ptr++ >> 2) & 63;  // Byte 4.
00065   alignment = *ptr & 3;   // Byte 5.
00066   combat = (*ptr++ >> 2) & 63;
00067   m_splits = (*ptr & 1) != 0; // Byte 6 (slimes).
00068   m_cant_die = (*ptr & 2) != 0;
00069   armor = (*ptr++ >> 4) & 15;
00070   ptr++;        // Unknown.
00071   reach = *ptr & 15;    // Byte 8 - weapon reach.
00072   weapon = (*ptr++ >> 4) & 15;
00073   flags = *ptr++;     // Byte 9.
00074   vulnerable = *ptr++;
00075   immune = *ptr++;
00076   m_cant_yell = (*ptr & (1<<5)) != 0;
00077   m_cant_bleed = (*ptr & (1<<6)) != 0;
00078   ptr++;
00079   ptr++;        // Unknown.
00080   equip_offset = *ptr++;    // Byte 13.
00081   return shapenum;
00082   }
00083 
00084 /*
00085  *  Get a default block for generic NPC's.
00086  */
00087 
00088 const Monster_info *Monster_info::get_default
00089   (
00090   )
00091   {
00092   if (!default_info.strength) // First time?
00093     {
00094     default_info.strength = 
00095     default_info.dexterity = 
00096     default_info.intelligence = 
00097     default_info.combat = 4;
00098     default_info.alignment = 0;   // Neutral.
00099     default_info.m_splits = default_info.m_cant_die = false;
00100     default_info.armor = 
00101     default_info.weapon = default_info.reach = 0;
00102     default_info.flags = (1<<(int) walk);
00103     default_info.equip_offset = 0;
00104     }
00105   return &default_info;
00106   }
00107 
00108 /*
00109  *  Set all the stats.
00110  */
00111 
00112 void Monster_info::set_stats
00113   (
00114   int str, int dex, int intel, int cmb, int armour,
00115   int wpn, int rch
00116   )
00117   {
00118   strength = str;
00119   dexterity = dex;
00120   intelligence = intel;
00121   combat = cmb;
00122   armor = armour;
00123   weapon = wpn;
00124   reach = rch;
00125   }
00126 

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