OpenMW
components/esm/loadnpc.hpp
Go to the documentation of this file.
00001 #ifndef OPENMW_ESM_NPC_H
00002 #define OPENMW_ESM_NPC_H
00003 
00004 #include <string>
00005 #include <vector>
00006 
00007 #include "defs.hpp"
00008 #include "loadcont.hpp"
00009 #include "aipackage.hpp"
00010 #include "spelllist.hpp"
00011 #include "loadskil.hpp"
00012 
00013 namespace ESM {
00014 
00015 class ESMReader;
00016 class ESMWriter;
00017 
00018 /*
00019  * NPC definition
00020  */
00021 
00022 struct NPC
00023 {
00024     static unsigned int sRecordId;
00025 
00026   // Services
00027   enum Services
00028     {
00029       // This merchant buys:
00030       Weapon        = 0x00001,
00031       Armor         = 0x00002,
00032       Clothing      = 0x00004,
00033       Books         = 0x00008,
00034       Ingredients   = 0x00010,
00035       Picks         = 0x00020,
00036       Probes        = 0x00040,
00037       Lights        = 0x00080,
00038       Apparatus     = 0x00100,
00039       RepairItem    = 0x00200,
00040       Misc          = 0x00400,
00041       Potions       = 0x02000,
00042 
00043       // Other services
00044       Spells        = 0x00800,
00045       MagicItems    = 0x01000,
00046       Training      = 0x04000, // What skills?
00047       Spellmaking   = 0x08000,
00048       Enchanting    = 0x10000,
00049       Repair        = 0x20000
00050     };
00051 
00052   enum Flags
00053     {
00054       Female    = 0x0001,
00055       Essential = 0x0002,
00056       Respawn   = 0x0004,
00057       Autocalc  = 0x0008,
00058       Skeleton  = 0x0400, // Skeleton blood effect (white)
00059       Metal     = 0x0800  // Metal blood effect (golden?)
00060     };
00061 
00062   enum NpcType
00063   {
00064     NPC_WITH_AUTOCALCULATED_STATS = 12,
00065     NPC_DEFAULT = 52
00066   };
00067 
00068     #pragma pack(push)
00069     #pragma pack(1)
00070 
00071     struct NPDTstruct52
00072     {
00073         short mLevel;
00074         unsigned char mStrength,
00075              mIntelligence,
00076              mWillpower,
00077              mAgility,
00078              mSpeed,
00079              mEndurance,
00080              mPersonality,
00081              mLuck;
00082 
00083         char mSkills[Skill::Length];
00084         char mReputation;
00085         short mHealth, mMana, mFatigue;
00086         char mDisposition, mFactionID, mRank;
00087         char mUnknown;
00088         int mGold;
00089     }; // 52 bytes
00090 
00091     struct NPDTstruct12
00092     {
00093         short mLevel;
00094         char mDisposition, mReputation, mRank;
00095         char mUnknown1, mUnknown2, mUnknown3;
00096         int mGold; // ?? not certain
00097     }; // 12 bytes
00098 
00099     struct Dest
00100     {
00101         Position    mPos;
00102         std::string mCellName;
00103     };
00104     #pragma pack(pop)
00105 
00106     char mNpdtType;
00107     NPDTstruct52 mNpdt52;
00108     NPDTstruct12 mNpdt12; // Use this if npdt52.gold == -10
00109 
00110     int mFlags;
00111 
00112     bool mPersistent;
00113 
00114     InventoryList mInventory;
00115     SpellList mSpells;
00116 
00117     AIData mAiData;
00118     bool mHasAI;
00119 
00120     std::vector<Dest> mTransport;
00121     AIPackageList     mAiPackage;
00122 
00123     std::string mId, mName, mModel, mRace, mClass, mFaction, mScript;
00124 
00125     // body parts
00126     std::string mHair, mHead;
00127 
00128     void load(ESMReader &esm);
00129     void save(ESMWriter &esm) const;
00130 
00131     bool isMale() const;
00132 
00133     void setIsMale(bool value);
00134 
00135     void blank();
00137 };
00138 }
00139 #endif