Exemplo n.º 1
0
    virtual void read(ESM::ESMReader &esm)
    {
        ESM::NPC npc;
        bool isDeleted = false;

        npc.load(esm, isDeleted);
        if (npc.mId != "player")
        {
            // Handles changes to the NPC struct, but since there is no index here
            // it will apply to ALL instances of the class. seems to be the reason for the
            // "feature" in MW where changing AI settings of one guard will change it for all guards of that refID.
            mContext->mNpcs[Misc::StringUtils::lowerCase(npc.mId)] = npc;
        }
        else
        {
            mContext->mPlayer.mObject.mCreatureStats.mLevel = npc.mNpdt52.mLevel;
            mContext->mPlayerBase = npc;
            std::map<int, float> empty;
            // FIXME: player start spells and birthsign spells aren't listed here,
            // need to fix openmw to account for this
            for (std::vector<std::string>::const_iterator it = npc.mSpells.mList.begin(); it != npc.mSpells.mList.end(); ++it)
                mContext->mPlayer.mObject.mCreatureStats.mSpells.mSpells[*it] = empty;

            // Clear the list now that we've written it, this prevents issues cropping up with
            // ensureCustomData() in OpenMW tripping over no longer existing spells, where an error would be fatal.
            mContext->mPlayerBase.mSpells.mList.clear();

            // Same with inventory. Actually it's strange this would contain something, since there's already an
            // inventory list in NPCC. There seems to be a fair amount of redundancy in this format.
            mContext->mPlayerBase.mInventory.mList.clear();
        }
    }