Пример #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();
        }
    }
Пример #2
0
    void RaceDialog::updatePreview()
    {
        ESM::NPC record = mPreview->getPrototype();
        record.mRace = mCurrentRaceId;
        record.setIsMale(mGenderIndex == 0);

        record.mHead = mAvailableHeads[mFaceIndex];
        record.mHair = mAvailableHairs[mHairIndex];

        mPreview->setPrototype(record);
        mPreviewDirty = true;
    }
Пример #3
0
    void RaceDialog::updatePreview()
    {
        ESM::NPC record = mPreview->getPrototype();
        record.mRace = mCurrentRaceId;
        record.setIsMale(mGenderIndex == 0);

        record.mHead = mAvailableHeads[mFaceIndex];
        record.mHair = mAvailableHairs[mHairIndex];

        try
        {
            mPreview->setPrototype(record);
        }
        catch (std::exception& e)
        {
            std::cerr << "Error creating preview: " << e.what() << std::endl;
        }
    }
Пример #4
0
    void RaceDialog::updatePreview()
    {
        ESM::NPC record = mPreview->getPrototype();
        record.mRace = mCurrentRaceId;
        record.setIsMale(mGenderIndex == 0);

        if (mFaceIndex >= 0 && mFaceIndex < int(mAvailableHeads.size()))
            record.mHead = mAvailableHeads[mFaceIndex];

        if (mHairIndex >= 0 && mHairIndex < int(mAvailableHairs.size()))
            record.mHair = mAvailableHairs[mHairIndex];

        try
        {
            mPreview->setPrototype(record);
        }
        catch (std::exception& e)
        {
            Log(Debug::Error) << "Error creating preview: " << e.what();
        }
    }
Пример #5
0
void RaceDialog::updatePreview()
{
    ESM::NPC record = mPreview->getPrototype();
    record.mRace = mCurrentRaceId;
    record.setIsMale(mGenderIndex == 0);

    std::string prefix =
        "b_n_" + mCurrentRaceId + ((record.isMale()) ? "_m_" : "_f_");

    std::string headIndex = (boost::format("%02d") % (mFaceIndex + 1)).str();
    std::string hairIndex = (boost::format("%02d") % (mHairIndex + 1)).str();

    record.mHead = prefix + "head_" + headIndex;
    record.mHair = prefix + "hair_" + hairIndex;

    const MWWorld::Store<ESM::BodyPart> &parts =
        MWBase::Environment::get().getWorld()->getStore().get<ESM::BodyPart>();

    if (parts.search(record.mHair) == 0) {
        record.mHair = prefix + "hair" + hairIndex;
    }
    mPreview->setPrototype(record);
}