mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-04-28 12:58:00 +03:00
Merge branch 'unawarenesstraining' into 'master'
Some checks are pending
Build and test / MacOS (push) Waiting to run
Build and test / Read .env file and expose it as output (push) Waiting to run
Build and test / Windows (2019) (push) Blocked by required conditions
Build and test / Windows (2022) (push) Blocked by required conditions
Build and test / Ubuntu (push) Waiting to run
Some checks are pending
Build and test / MacOS (push) Waiting to run
Build and test / Read .env file and expose it as output (push) Waiting to run
Build and test / Windows (2019) (push) Blocked by required conditions
Build and test / Windows (2022) (push) Blocked by required conditions
Build and test / Ubuntu (push) Waiting to run
Cache awareness rolls for 5 seconds to make sneaking easier See merge request OpenMW/openmw!4434
This commit is contained in:
commit
0ecf885b83
4 changed files with 28 additions and 2 deletions
|
@ -407,6 +407,7 @@ namespace MWMechanics
|
|||
|
||||
void Actors::updateActor(const MWWorld::Ptr& ptr, float duration) const
|
||||
{
|
||||
ptr.getClass().getCreatureStats(ptr).updateAwareness(duration);
|
||||
// magic effects
|
||||
adjustMagicEffects(ptr, duration);
|
||||
|
||||
|
|
|
@ -695,4 +695,24 @@ namespace MWMechanics
|
|||
{
|
||||
return mSummonGraveyard;
|
||||
}
|
||||
|
||||
void CreatureStats::updateAwareness(float duration)
|
||||
{
|
||||
mAwarenessTimer += duration;
|
||||
// Only reroll for awareness every 5 seconds
|
||||
if (mAwarenessTimer >= 5.f)
|
||||
{
|
||||
mAwarenessTimer = 0.f;
|
||||
mAwarenessRoll = -1;
|
||||
}
|
||||
}
|
||||
|
||||
int CreatureStats::getAwarenessRoll()
|
||||
{
|
||||
if (mAwarenessRoll >= 0)
|
||||
return mAwarenessRoll;
|
||||
auto& prng = MWBase::Environment::get().getWorld()->getPrng();
|
||||
mAwarenessRoll = Misc::Rng::roll0to99(prng);
|
||||
return mAwarenessRoll;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -90,6 +90,9 @@ namespace MWMechanics
|
|||
// This may be necessary when the creature is in an inactive cell.
|
||||
std::vector<int> mSummonGraveyard;
|
||||
|
||||
float mAwarenessTimer = 0.f;
|
||||
int mAwarenessRoll = -1;
|
||||
|
||||
protected:
|
||||
std::string mAttackType;
|
||||
int mLevel = 0;
|
||||
|
@ -303,6 +306,9 @@ namespace MWMechanics
|
|||
void setTeleported(bool v) { mTeleported = v; }
|
||||
|
||||
const std::map<ESM::RefId, AttributeValue>& getAttributes() const { return mAttributes; }
|
||||
|
||||
void updateAwareness(float duration);
|
||||
int getAwarenessRoll();
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -1657,8 +1657,7 @@ namespace MWMechanics
|
|||
}
|
||||
|
||||
float target = x - y;
|
||||
auto& prng = MWBase::Environment::get().getWorld()->getPrng();
|
||||
return (Misc::Rng::roll0to99(prng) >= target);
|
||||
return observerStats.getAwarenessRoll() >= target;
|
||||
}
|
||||
|
||||
void MechanicsManager::startCombat(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue