mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-02-23 06:41:08 +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.
|
// 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.
|
// 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);
|
const MWMechanics::NpcStats& stats = getNpcStats(ptr);
|
||||||
bool godmode = ptr == MWMechanics::getPlayer() && MWBase::Environment::get().getWorld()->getGodModeState();
|
if (stats.isParalyzed() || stats.getKnockedDown() || stats.isDead())
|
||||||
if ((!godmode && stats.isParalyzed()) || stats.getKnockedDown() || stats.isDead())
|
|
||||||
return 0.f;
|
return 0.f;
|
||||||
|
|
||||||
const MWBase::World* world = MWBase::Environment::get().getWorld();
|
const MWBase::World* world = MWBase::Environment::get().getWorld();
|
||||||
@ -1034,8 +1033,7 @@ namespace MWClass
|
|||||||
return 0.f;
|
return 0.f;
|
||||||
|
|
||||||
const MWMechanics::NpcStats& stats = getNpcStats(ptr);
|
const MWMechanics::NpcStats& stats = getNpcStats(ptr);
|
||||||
bool godmode = ptr == MWMechanics::getPlayer() && MWBase::Environment::get().getWorld()->getGodModeState();
|
if (stats.isParalyzed() || stats.getKnockedDown() || stats.isDead())
|
||||||
if ((!godmode && stats.isParalyzed()) || stats.getKnockedDown() || stats.isDead())
|
|
||||||
return 0.f;
|
return 0.f;
|
||||||
|
|
||||||
const GMST& gmst = getGmst();
|
const GMST& gmst = getGmst();
|
||||||
|
@ -749,8 +749,7 @@ namespace MWGui
|
|||||||
|
|
||||||
// Player must not be paralyzed, knocked down, or dead to pick up an item.
|
// Player must not be paralyzed, knocked down, or dead to pick up an item.
|
||||||
const MWMechanics::NpcStats& playerStats = player.getClass().getNpcStats(player);
|
const MWMechanics::NpcStats& playerStats = player.getClass().getNpcStats(player);
|
||||||
bool godmode = MWBase::Environment::get().getWorld()->getGodModeState();
|
if (playerStats.isParalyzed() || playerStats.getKnockedDown() || playerStats.isDead())
|
||||||
if ((!godmode && playerStats.isParalyzed()) || playerStats.getKnockedDown() || playerStats.isDead())
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
MWBase::Environment::get().getMechanicsManager()->itemTaken(player, object, MWWorld::Ptr(), count);
|
MWBase::Environment::get().getMechanicsManager()->itemTaken(player, object, MWWorld::Ptr(), count);
|
||||||
@ -789,8 +788,7 @@ namespace MWGui
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
const MWMechanics::CreatureStats& stats = player.getClass().getCreatureStats(player);
|
const MWMechanics::CreatureStats& stats = player.getClass().getCreatureStats(player);
|
||||||
bool godmode = MWBase::Environment::get().getWorld()->getGodModeState();
|
if (stats.isParalyzed() || stats.getKnockedDown() || stats.isDead() || stats.getHitRecovery())
|
||||||
if ((!godmode && stats.isParalyzed()) || stats.getKnockedDown() || stats.isDead() || stats.getHitRecovery())
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
ItemModel::ModelIndex selected = -1;
|
ItemModel::ModelIndex selected = -1;
|
||||||
|
@ -353,8 +353,7 @@ namespace MWGui
|
|||||||
bool isDelayNeeded = MWBase::Environment::get().getMechanicsManager()->isAttackingOrSpell(player)
|
bool isDelayNeeded = MWBase::Environment::get().getMechanicsManager()->isAttackingOrSpell(player)
|
||||||
|| playerStats.getKnockedDown() || playerStats.getHitRecovery();
|
|| playerStats.getKnockedDown() || playerStats.getHitRecovery();
|
||||||
|
|
||||||
bool godmode = MWBase::Environment::get().getWorld()->getGodModeState();
|
bool isReturnNeeded = playerStats.isParalyzed() || playerStats.isDead();
|
||||||
bool isReturnNeeded = (!godmode && playerStats.isParalyzed()) || playerStats.isDead();
|
|
||||||
|
|
||||||
if (isReturnNeeded)
|
if (isReturnNeeded)
|
||||||
{
|
{
|
||||||
|
@ -236,9 +236,8 @@ namespace MWGui
|
|||||||
if (MWBase::Environment::get().getMechanicsManager()->isAttackingOrSpell(player))
|
if (MWBase::Environment::get().getMechanicsManager()->isAttackingOrSpell(player))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
bool godmode = MWBase::Environment::get().getWorld()->getGodModeState();
|
|
||||||
const MWMechanics::CreatureStats& stats = player.getClass().getCreatureStats(player);
|
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;
|
return;
|
||||||
|
|
||||||
mSpellView->setModel(new SpellModel(MWMechanics::getPlayer()));
|
mSpellView->setModel(new SpellModel(MWMechanics::getPlayer()));
|
||||||
|
@ -1482,7 +1482,6 @@ namespace MWMechanics
|
|||||||
if (!playerHitAttemptActor.isInCell())
|
if (!playerHitAttemptActor.isInCell())
|
||||||
player.getClass().getCreatureStats(player).setHitAttemptActorId(-1);
|
player.getClass().getCreatureStats(player).setHitAttemptActorId(-1);
|
||||||
}
|
}
|
||||||
const bool godmode = MWBase::Environment::get().getWorld()->getGodModeState();
|
|
||||||
const int actorsProcessingRange = Settings::game().mActorsProcessingRange;
|
const int actorsProcessingRange = Settings::game().mActorsProcessingRange;
|
||||||
|
|
||||||
// AI and magic effects update
|
// AI and magic effects update
|
||||||
@ -1634,8 +1633,7 @@ namespace MWMechanics
|
|||||||
world->setActorActive(actor.getPtr(), true);
|
world->setActorActive(actor.getPtr(), true);
|
||||||
|
|
||||||
const bool isDead = actor.getPtr().getClass().getCreatureStats(actor.getPtr()).isDead();
|
const bool isDead = actor.getPtr().getClass().getCreatureStats(actor.getPtr()).isDead();
|
||||||
if (!isDead && (!godmode || !isPlayer)
|
if (!isDead && actor.getPtr().getClass().getCreatureStats(actor.getPtr()).isParalyzed())
|
||||||
&& actor.getPtr().getClass().getCreatureStats(actor.getPtr()).isParalyzed())
|
|
||||||
ctrl.skipAnim();
|
ctrl.skipAnim();
|
||||||
|
|
||||||
// Handle player last, in case a cell transition occurs by casting a teleportation spell
|
// Handle player last, in case a cell transition occurs by casting a teleportation spell
|
||||||
|
@ -241,6 +241,11 @@ namespace MWMechanics
|
|||||||
|
|
||||||
bool CreatureStats::isParalyzed() const
|
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;
|
return mMagicEffects.getOrDefault(ESM::MagicEffect::Paralyze).getMagnitude() > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -183,8 +183,7 @@ namespace MWWorld
|
|||||||
|
|
||||||
MWWorld::Ptr player = getPlayer();
|
MWWorld::Ptr player = getPlayer();
|
||||||
const MWMechanics::NpcStats& playerStats = player.getClass().getNpcStats(player);
|
const MWMechanics::NpcStats& playerStats = player.getClass().getNpcStats(player);
|
||||||
bool godmode = MWBase::Environment::get().getWorld()->getGodModeState();
|
if (playerStats.isParalyzed() || playerStats.getKnockedDown() || playerStats.isDead())
|
||||||
if ((!godmode && playerStats.isParalyzed()) || playerStats.getKnockedDown() || playerStats.isDead())
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
MWWorld::Ptr toActivate = MWBase::Environment::get().getWorld()->getFacedObject();
|
MWWorld::Ptr toActivate = MWBase::Environment::get().getWorld()->getFacedObject();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user