forked from teamnwah/openmw-tes3coop
Initial work on implementing corprus worsening effect
This commit is contained in:
parent
4e521d1aca
commit
3722c7adc3
3 changed files with 69 additions and 1 deletions
|
@ -477,6 +477,25 @@ namespace MWMechanics
|
||||||
creatureStats.setAttribute(i, stat);
|
creatureStats.setAttribute(i, stat);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
Spells & spells = creatureStats.getSpells();
|
||||||
|
for (Spells::TIterator it = spells.begin(); it != spells.end(); ++it)
|
||||||
|
{
|
||||||
|
if (spells.mCorprusSpells.find(it->first) != spells.mCorprusSpells.end())
|
||||||
|
{
|
||||||
|
const ESM::Spell* spell = MWBase::Environment::get().getWorld()->getStore().get<ESM::Spell>().find(it->first);
|
||||||
|
|
||||||
|
if (MWBase::Environment::get().getWorld()->getTimeStamp() >= spells.mCorprusSpells[it->first].mNextWorsening)
|
||||||
|
{
|
||||||
|
spells.worsenCorprus(it->first);
|
||||||
|
|
||||||
|
if (ptr.getRefData().getHandle() == "player")
|
||||||
|
MWBase::Environment::get().getWindowManager()->messageBox("#{sMagicCorprusWorsens}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// dynamic stats
|
// dynamic stats
|
||||||
for(int i = 0;i < 3;++i)
|
for(int i = 0;i < 3;++i)
|
||||||
{
|
{
|
||||||
|
|
|
@ -44,6 +44,25 @@ namespace MWMechanics
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool hasCorprusEffect = false;
|
||||||
|
for (std::vector<ESM::ENAMstruct>::const_iterator effectIt = spell->mEffects.mList.begin(); effectIt != spell->mEffects.mList.end(); ++effectIt)
|
||||||
|
{
|
||||||
|
if (effectIt->mEffectID == ESM::MagicEffect::Corprus)
|
||||||
|
{
|
||||||
|
hasCorprusEffect = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (hasCorprusEffect)
|
||||||
|
{
|
||||||
|
CorprusStats corprus;
|
||||||
|
corprus.mWorsenings = 0;
|
||||||
|
corprus.mNextWorsening = MWBase::Environment::get().getWorld()->getTimeStamp() + CorprusStats::sWorseningPeriod;
|
||||||
|
|
||||||
|
mCorprusSpells[spellId] = corprus;
|
||||||
|
}
|
||||||
|
|
||||||
mSpells.insert (std::make_pair (Misc::StringUtils::lowerCase(spellId), random));
|
mSpells.insert (std::make_pair (Misc::StringUtils::lowerCase(spellId), random));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -52,10 +71,14 @@ namespace MWMechanics
|
||||||
{
|
{
|
||||||
std::string lower = Misc::StringUtils::lowerCase(spellId);
|
std::string lower = Misc::StringUtils::lowerCase(spellId);
|
||||||
TContainer::iterator iter = mSpells.find (lower);
|
TContainer::iterator iter = mSpells.find (lower);
|
||||||
|
std::map<std::string, CorprusStats>::iterator corprusIt = mCorprusSpells.find(lower);
|
||||||
|
|
||||||
if (iter!=mSpells.end())
|
if (iter!=mSpells.end())
|
||||||
mSpells.erase (iter);
|
mSpells.erase (iter);
|
||||||
|
|
||||||
|
if (corprusIt != mCorprusSpells.end())
|
||||||
|
mCorprusSpells.erase(corprusIt);
|
||||||
|
|
||||||
if (spellId==mSelectedSpell)
|
if (spellId==mSelectedSpell)
|
||||||
mSelectedSpell.clear();
|
mSelectedSpell.clear();
|
||||||
}
|
}
|
||||||
|
@ -81,7 +104,15 @@ namespace MWMechanics
|
||||||
if (iter->second.find(i) != iter->second.end())
|
if (iter->second.find(i) != iter->second.end())
|
||||||
random = iter->second.at(i);
|
random = iter->second.at(i);
|
||||||
|
|
||||||
effects.add (*it, it->mMagnMin + (it->mMagnMax - it->mMagnMin) * random);
|
int applyTimes = 1;
|
||||||
|
if (mCorprusSpells.find(spell->mId) != mCorprusSpells.end())
|
||||||
|
{
|
||||||
|
const ESM::MagicEffect* effect = MWBase::Environment::get().getWorld()->getStore().get<ESM::MagicEffect>().find(spell->mEffects.mList.front().mEffectID);
|
||||||
|
if ((it->mEffectID != ESM::MagicEffect::Corprus) && (effect->mData.mFlags & ESM::MagicEffect::UncappedDamage)) // APPLIED_ONCE
|
||||||
|
applyTimes += mCorprusSpells.at(spell->mId).mWorsenings;
|
||||||
|
}
|
||||||
|
for (int j = 0; j < applyTimes; j++)
|
||||||
|
effects.add (*it, it->mMagnMin + (it->mMagnMax - it->mMagnMin) * random);
|
||||||
++i;
|
++i;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -216,6 +247,12 @@ namespace MWMechanics
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Spells::worsenCorprus(const std::string &corpSpellId)
|
||||||
|
{
|
||||||
|
mCorprusSpells[corpSpellId].mNextWorsening = MWBase::Environment::get().getWorld()->getTimeStamp() + CorprusStats::sWorseningPeriod;
|
||||||
|
mCorprusSpells[corpSpellId].mWorsenings++;
|
||||||
|
}
|
||||||
|
|
||||||
bool Spells::canUsePower(const std::string &power) const
|
bool Spells::canUsePower(const std::string &power) const
|
||||||
{
|
{
|
||||||
std::map<std::string, MWWorld::TimeStamp>::const_iterator it = mUsedPowers.find(power);
|
std::map<std::string, MWWorld::TimeStamp>::const_iterator it = mUsedPowers.find(power);
|
||||||
|
|
|
@ -44,6 +44,18 @@ namespace MWMechanics
|
||||||
|
|
||||||
std::map<std::string, MWWorld::TimeStamp> mUsedPowers;
|
std::map<std::string, MWWorld::TimeStamp> mUsedPowers;
|
||||||
|
|
||||||
|
public:
|
||||||
|
struct CorprusStats
|
||||||
|
{
|
||||||
|
static const int sWorseningPeriod = 24;
|
||||||
|
|
||||||
|
int mWorsenings;
|
||||||
|
MWWorld::TimeStamp mNextWorsening;
|
||||||
|
};
|
||||||
|
|
||||||
|
std::map<std::string, CorprusStats> mCorprusSpells;
|
||||||
|
void worsenCorprus(const std::string &corpSpellId);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
bool canUsePower (const std::string& power) const;
|
bool canUsePower (const std::string& power) const;
|
||||||
|
|
Loading…
Reference in a new issue