mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-02-22 12:39:59 +00:00
Move paralysis god mode checks to CreatureStats
This commit is contained in:
parent
2be6116ef6
commit
ae7861abe4
@ -984,8 +984,7 @@ namespace MWClass
|
||||
// TODO: This function is called several times per frame for each NPC.
|
||||
// It would be better to calculate it only once per frame for each NPC and save the result in CreatureStats.
|
||||
const MWMechanics::NpcStats& stats = getNpcStats(ptr);
|
||||
bool godmode = ptr == MWMechanics::getPlayer() && MWBase::Environment::get().getWorld()->getGodModeState();
|
||||
if ((!godmode && stats.isParalyzed()) || stats.getKnockedDown() || stats.isDead())
|
||||
if (stats.isParalyzed() || stats.getKnockedDown() || stats.isDead())
|
||||
return 0.f;
|
||||
|
||||
const MWBase::World* world = MWBase::Environment::get().getWorld();
|
||||
@ -1034,8 +1033,7 @@ namespace MWClass
|
||||
return 0.f;
|
||||
|
||||
const MWMechanics::NpcStats& stats = getNpcStats(ptr);
|
||||
bool godmode = ptr == MWMechanics::getPlayer() && MWBase::Environment::get().getWorld()->getGodModeState();
|
||||
if ((!godmode && stats.isParalyzed()) || stats.getKnockedDown() || stats.isDead())
|
||||
if (stats.isParalyzed() || stats.getKnockedDown() || stats.isDead())
|
||||
return 0.f;
|
||||
|
||||
const GMST& gmst = getGmst();
|
||||
|
@ -749,8 +749,7 @@ namespace MWGui
|
||||
|
||||
// Player must not be paralyzed, knocked down, or dead to pick up an item.
|
||||
const MWMechanics::NpcStats& playerStats = player.getClass().getNpcStats(player);
|
||||
bool godmode = MWBase::Environment::get().getWorld()->getGodModeState();
|
||||
if ((!godmode && playerStats.isParalyzed()) || playerStats.getKnockedDown() || playerStats.isDead())
|
||||
if (playerStats.isParalyzed() || playerStats.getKnockedDown() || playerStats.isDead())
|
||||
return;
|
||||
|
||||
MWBase::Environment::get().getMechanicsManager()->itemTaken(player, object, MWWorld::Ptr(), count);
|
||||
@ -789,8 +788,7 @@ namespace MWGui
|
||||
return;
|
||||
|
||||
const MWMechanics::CreatureStats& stats = player.getClass().getCreatureStats(player);
|
||||
bool godmode = MWBase::Environment::get().getWorld()->getGodModeState();
|
||||
if ((!godmode && stats.isParalyzed()) || stats.getKnockedDown() || stats.isDead() || stats.getHitRecovery())
|
||||
if (stats.isParalyzed() || stats.getKnockedDown() || stats.isDead() || stats.getHitRecovery())
|
||||
return;
|
||||
|
||||
ItemModel::ModelIndex selected = -1;
|
||||
|
@ -353,8 +353,7 @@ namespace MWGui
|
||||
bool isDelayNeeded = MWBase::Environment::get().getMechanicsManager()->isAttackingOrSpell(player)
|
||||
|| playerStats.getKnockedDown() || playerStats.getHitRecovery();
|
||||
|
||||
bool godmode = MWBase::Environment::get().getWorld()->getGodModeState();
|
||||
bool isReturnNeeded = (!godmode && playerStats.isParalyzed()) || playerStats.isDead();
|
||||
bool isReturnNeeded = playerStats.isParalyzed() || playerStats.isDead();
|
||||
|
||||
if (isReturnNeeded)
|
||||
{
|
||||
|
@ -236,9 +236,8 @@ namespace MWGui
|
||||
if (MWBase::Environment::get().getMechanicsManager()->isAttackingOrSpell(player))
|
||||
return;
|
||||
|
||||
bool godmode = MWBase::Environment::get().getWorld()->getGodModeState();
|
||||
const MWMechanics::CreatureStats& stats = player.getClass().getCreatureStats(player);
|
||||
if ((!godmode && stats.isParalyzed()) || stats.getKnockedDown() || stats.isDead() || stats.getHitRecovery())
|
||||
if (stats.isParalyzed() || stats.getKnockedDown() || stats.isDead() || stats.getHitRecovery())
|
||||
return;
|
||||
|
||||
mSpellView->setModel(new SpellModel(MWMechanics::getPlayer()));
|
||||
|
@ -1482,7 +1482,6 @@ namespace MWMechanics
|
||||
if (!playerHitAttemptActor.isInCell())
|
||||
player.getClass().getCreatureStats(player).setHitAttemptActorId(-1);
|
||||
}
|
||||
const bool godmode = MWBase::Environment::get().getWorld()->getGodModeState();
|
||||
const int actorsProcessingRange = Settings::game().mActorsProcessingRange;
|
||||
|
||||
// AI and magic effects update
|
||||
@ -1634,8 +1633,7 @@ namespace MWMechanics
|
||||
world->setActorActive(actor.getPtr(), true);
|
||||
|
||||
const bool isDead = actor.getPtr().getClass().getCreatureStats(actor.getPtr()).isDead();
|
||||
if (!isDead && (!godmode || !isPlayer)
|
||||
&& actor.getPtr().getClass().getCreatureStats(actor.getPtr()).isParalyzed())
|
||||
if (!isDead && actor.getPtr().getClass().getCreatureStats(actor.getPtr()).isParalyzed())
|
||||
ctrl.skipAnim();
|
||||
|
||||
// Handle player last, in case a cell transition occurs by casting a teleportation spell
|
||||
|
@ -241,6 +241,11 @@ namespace MWMechanics
|
||||
|
||||
bool CreatureStats::isParalyzed() const
|
||||
{
|
||||
MWBase::World* world = MWBase::Environment::get().getWorld();
|
||||
const MWWorld::Ptr player = world->getPlayerPtr();
|
||||
if (world->getGodModeState() && this == &player.getClass().getCreatureStats(player))
|
||||
return false;
|
||||
|
||||
return mMagicEffects.getOrDefault(ESM::MagicEffect::Paralyze).getMagnitude() > 0;
|
||||
}
|
||||
|
||||
|
@ -183,8 +183,7 @@ namespace MWWorld
|
||||
|
||||
MWWorld::Ptr player = getPlayer();
|
||||
const MWMechanics::NpcStats& playerStats = player.getClass().getNpcStats(player);
|
||||
bool godmode = MWBase::Environment::get().getWorld()->getGodModeState();
|
||||
if ((!godmode && playerStats.isParalyzed()) || playerStats.getKnockedDown() || playerStats.isDead())
|
||||
if (playerStats.isParalyzed() || playerStats.getKnockedDown() || playerStats.isDead())
|
||||
return;
|
||||
|
||||
MWWorld::Ptr toActivate = MWBase::Environment::get().getWorld()->getFacedObject();
|
||||
|
Loading…
x
Reference in New Issue
Block a user