forked from mirror/openmw-tes3mp
Implement fWerewolfHealth GMST (fixes #4142)
This commit is contained in:
parent
9b8c56761b
commit
e6d9bce519
3 changed files with 33 additions and 25 deletions
|
@ -1719,11 +1719,11 @@ namespace MWMechanics
|
||||||
{
|
{
|
||||||
if (werewolf)
|
if (werewolf)
|
||||||
{
|
{
|
||||||
player->saveSkillsAttributes();
|
player->saveStats();
|
||||||
player->setWerewolfSkillsAttributes();
|
player->setWerewolfStats();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
player->restoreSkillsAttributes();
|
player->restoreStats();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Werewolfs can not cast spells, so we need to unset the prepared spell if there is one.
|
// Werewolfs can not cast spells, so we need to unset the prepared spell if there is one.
|
||||||
|
|
|
@ -47,37 +47,45 @@ namespace MWWorld
|
||||||
mPlayer.mData.setPosition(playerPos);
|
mPlayer.mData.setPosition(playerPos);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Player::saveSkillsAttributes()
|
void Player::saveStats()
|
||||||
{
|
{
|
||||||
MWMechanics::NpcStats& stats = getPlayer().getClass().getNpcStats(getPlayer());
|
MWMechanics::NpcStats& stats = getPlayer().getClass().getNpcStats(getPlayer());
|
||||||
|
|
||||||
for (int i=0; i<ESM::Skill::Length; ++i)
|
for (int i=0; i<ESM::Skill::Length; ++i)
|
||||||
mSaveSkills[i] = stats.getSkill(i);
|
mSaveSkills[i] = stats.getSkill(i);
|
||||||
for (int i=0; i<ESM::Attribute::Length; ++i)
|
for (int i=0; i<ESM::Attribute::Length; ++i)
|
||||||
mSaveAttributes[i] = stats.getAttribute(i);
|
mSaveAttributes[i] = stats.getAttribute(i);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Player::restoreSkillsAttributes()
|
void Player::restoreStats()
|
||||||
{
|
|
||||||
MWMechanics::NpcStats& stats = getPlayer().getClass().getNpcStats(getPlayer());
|
|
||||||
for (int i=0; i<ESM::Skill::Length; ++i)
|
|
||||||
stats.setSkill(i, mSaveSkills[i]);
|
|
||||||
for (int i=0; i<ESM::Attribute::Length; ++i)
|
|
||||||
stats.setAttribute(i, mSaveAttributes[i]);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Player::setWerewolfSkillsAttributes()
|
|
||||||
{
|
{
|
||||||
const MWWorld::Store<ESM::GameSetting>& gmst = MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>();
|
const MWWorld::Store<ESM::GameSetting>& gmst = MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>();
|
||||||
MWMechanics::NpcStats& stats = getPlayer().getClass().getNpcStats(getPlayer());
|
MWMechanics::CreatureStats& creatureStats = getPlayer().getClass().getCreatureStats(getPlayer());
|
||||||
|
MWMechanics::NpcStats& npcStats = getPlayer().getClass().getNpcStats(getPlayer());
|
||||||
|
MWMechanics::DynamicStat<float> health = creatureStats.getDynamic(0);
|
||||||
|
creatureStats.setHealth(int(health.getBase() / gmst.find("fWereWolfHealth")->getFloat()));
|
||||||
|
for (int i=0; i<ESM::Skill::Length; ++i)
|
||||||
|
npcStats.setSkill(i, mSaveSkills[i]);
|
||||||
|
for (int i=0; i<ESM::Attribute::Length; ++i)
|
||||||
|
npcStats.setAttribute(i, mSaveAttributes[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Player::setWerewolfStats()
|
||||||
|
{
|
||||||
|
const MWWorld::Store<ESM::GameSetting>& gmst = MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>();
|
||||||
|
MWMechanics::CreatureStats& creatureStats = getPlayer().getClass().getCreatureStats(getPlayer());
|
||||||
|
MWMechanics::NpcStats& npcStats = getPlayer().getClass().getNpcStats(getPlayer());
|
||||||
|
MWMechanics::DynamicStat<float> health = creatureStats.getDynamic(0);
|
||||||
|
creatureStats.setHealth(int(health.getBase() * gmst.find("fWereWolfHealth")->getFloat()));
|
||||||
for(size_t i = 0;i < ESM::Attribute::Length;++i)
|
for(size_t i = 0;i < ESM::Attribute::Length;++i)
|
||||||
{
|
{
|
||||||
// Oh, Bethesda. It's "Intelligence".
|
// Oh, Bethesda. It's "Intelligence".
|
||||||
std::string name = "fWerewolf"+((i==ESM::Attribute::Intelligence) ? std::string("Intellegence") :
|
std::string name = "fWerewolf"+((i==ESM::Attribute::Intelligence) ? std::string("Intellegence") :
|
||||||
ESM::Attribute::sAttributeNames[i]);
|
ESM::Attribute::sAttributeNames[i]);
|
||||||
|
|
||||||
MWMechanics::AttributeValue value = stats.getAttribute(i);
|
MWMechanics::AttributeValue value = npcStats.getAttribute(i);
|
||||||
value.setBase(int(gmst.find(name)->getFloat()));
|
value.setBase(int(gmst.find(name)->getFloat()));
|
||||||
stats.setAttribute(i, value);
|
npcStats.setAttribute(i, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
for(size_t i = 0;i < ESM::Skill::Length;i++)
|
for(size_t i = 0;i < ESM::Skill::Length;i++)
|
||||||
|
@ -90,9 +98,9 @@ namespace MWWorld
|
||||||
std::string name = "fWerewolf"+((i==ESM::Skill::Mercantile) ? std::string("Merchantile") :
|
std::string name = "fWerewolf"+((i==ESM::Skill::Mercantile) ? std::string("Merchantile") :
|
||||||
ESM::Skill::sSkillNames[i]);
|
ESM::Skill::sSkillNames[i]);
|
||||||
|
|
||||||
MWMechanics::SkillValue value = stats.getSkill(i);
|
MWMechanics::SkillValue value = npcStats.getSkill(i);
|
||||||
value.setBase(int(gmst.find(name)->getFloat()));
|
value.setBase(int(gmst.find(name)->getFloat()));
|
||||||
stats.setSkill(i, value);
|
npcStats.setSkill(i, value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -366,8 +374,8 @@ namespace MWWorld
|
||||||
|
|
||||||
if (player.mObject.mNpcStats.mWerewolfDeprecatedData && player.mObject.mNpcStats.mIsWerewolf)
|
if (player.mObject.mNpcStats.mWerewolfDeprecatedData && player.mObject.mNpcStats.mIsWerewolf)
|
||||||
{
|
{
|
||||||
saveSkillsAttributes();
|
saveStats();
|
||||||
setWerewolfSkillsAttributes();
|
setWerewolfStats();
|
||||||
}
|
}
|
||||||
|
|
||||||
getPlayer().getClass().getCreatureStats(getPlayer()).getAiSequence().clear();
|
getPlayer().getClass().getCreatureStats(getPlayer()).getAiSequence().clear();
|
||||||
|
|
|
@ -46,7 +46,7 @@ namespace MWWorld
|
||||||
int mCurrentCrimeId; // the id assigned witnesses
|
int mCurrentCrimeId; // the id assigned witnesses
|
||||||
int mPaidCrimeId; // the last id paid off (0 bounty)
|
int mPaidCrimeId; // the last id paid off (0 bounty)
|
||||||
|
|
||||||
// Saved skills and attributes prior to becoming a werewolf
|
// Saved stats prior to becoming a werewolf
|
||||||
MWMechanics::SkillValue mSaveSkills[ESM::Skill::Length];
|
MWMechanics::SkillValue mSaveSkills[ESM::Skill::Length];
|
||||||
MWMechanics::AttributeValue mSaveAttributes[ESM::Attribute::Length];
|
MWMechanics::AttributeValue mSaveAttributes[ESM::Attribute::Length];
|
||||||
|
|
||||||
|
@ -56,9 +56,9 @@ namespace MWWorld
|
||||||
|
|
||||||
Player(const ESM::NPC *player);
|
Player(const ESM::NPC *player);
|
||||||
|
|
||||||
void saveSkillsAttributes();
|
void saveStats();
|
||||||
void restoreSkillsAttributes();
|
void restoreStats();
|
||||||
void setWerewolfSkillsAttributes();
|
void setWerewolfStats();
|
||||||
|
|
||||||
// For mark/recall magic effects
|
// For mark/recall magic effects
|
||||||
void markPosition (CellStore* markedCell, const ESM::Position& markedPosition);
|
void markPosition (CellStore* markedCell, const ESM::Position& markedPosition);
|
||||||
|
|
Loading…
Reference in a new issue