forked from mirror/openmw-tes3mp
added spell list to creature stats (for now only type Ability; magic effects not applied yet), generate spell list according to race and birthsign during character creation
This commit is contained in:
parent
770276281b
commit
eeca39220b
3 changed files with 50 additions and 2 deletions
|
@ -1,6 +1,9 @@
|
|||
#ifndef GAME_MWMECHANICS_CREATURESTATS_H
|
||||
#define GAME_MWMECHANICS_CREATURESTATS_H
|
||||
|
||||
#include <set>
|
||||
#include <string>
|
||||
|
||||
#include "stat.hpp"
|
||||
|
||||
namespace MWMechanics
|
||||
|
@ -10,6 +13,7 @@ namespace MWMechanics
|
|||
Stat<int> mAttributes[8];
|
||||
DynamicStat<int> mDynamic[3]; // health, magicka, fatigue
|
||||
int mLevel;
|
||||
std::set<std::string> mAbilities;
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -22,6 +22,7 @@ namespace MWMechanics
|
|||
|
||||
// reset
|
||||
creatureStats.mLevel = player->npdt52.level;
|
||||
creatureStats.mAbilities.clear();
|
||||
|
||||
for (int i=0; i<27; ++i)
|
||||
npcStats.mSkill[i].setBase (player->npdt52.skills[i]);
|
||||
|
@ -65,13 +66,25 @@ namespace MWMechanics
|
|||
}
|
||||
}
|
||||
|
||||
// TODO handle magic effects
|
||||
for (std::vector<std::string>::const_iterator iter (race->powers.list.begin());
|
||||
iter!=race->powers.list.end(); ++iter)
|
||||
{
|
||||
insertSpell (*iter, ptr);
|
||||
}
|
||||
}
|
||||
|
||||
// birthsign
|
||||
if (!mEnvironment.mWorld->getPlayerPos().getBirthsign().empty())
|
||||
{
|
||||
// TODO handle magic effects
|
||||
const ESM::BirthSign *sign =
|
||||
mEnvironment.mWorld->getStore().birthSigns.find (
|
||||
mEnvironment.mWorld->getPlayerPos().getBirthsign());
|
||||
|
||||
for (std::vector<std::string>::const_iterator iter (sign->powers.list.begin());
|
||||
iter!=sign->powers.list.end(); ++iter)
|
||||
{
|
||||
insertSpell (*iter, ptr);
|
||||
}
|
||||
}
|
||||
|
||||
// class
|
||||
|
@ -139,6 +152,35 @@ namespace MWMechanics
|
|||
creatureStats.mDynamic[i].setCurrent (creatureStats.mDynamic[i].getModified());
|
||||
}
|
||||
|
||||
void MechanicsManager::insertSpell (const std::string& id, MWWorld::Ptr& creature)
|
||||
{
|
||||
MWMechanics::CreatureStats& creatureStats =
|
||||
MWWorld::Class::get (creature).getCreatureStats (creature);
|
||||
|
||||
const ESM::Spell *spell = mEnvironment.mWorld->getStore().spells.find (id);
|
||||
|
||||
switch (spell->data.type)
|
||||
{
|
||||
case ESM::Spell::ST_Ability:
|
||||
|
||||
if (creatureStats.mAbilities.find (id)==creatureStats.mAbilities.end())
|
||||
{
|
||||
creatureStats.mAbilities.insert (id);
|
||||
// TODO apply effects
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
// TODO ST_SPELL, ST_Blight, ST_Disease, ST_Curse, ST_Power
|
||||
|
||||
default:
|
||||
|
||||
std::cout
|
||||
<< "adding unsupported spell type (" << spell->data.type
|
||||
<< ") to creature: " << id << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
MechanicsManager::MechanicsManager (MWWorld::Environment& environment)
|
||||
: mEnvironment (environment), mUpdatePlayer (true), mClassSelected (false),
|
||||
mRaceSelected (false)
|
||||
|
|
|
@ -30,6 +30,8 @@ namespace MWMechanics
|
|||
///< build player according to stored class/race/birthsign information. Will
|
||||
/// default to the values of the ESM::NPC object, if no explicit information is given.
|
||||
|
||||
void insertSpell (const std::string& id, MWWorld::Ptr& creature);
|
||||
|
||||
public:
|
||||
|
||||
MechanicsManager (MWWorld::Environment& environment);
|
||||
|
|
Loading…
Reference in a new issue