@ -34,6 +34,7 @@
# include "actor.hpp"
# include "summoning.hpp"
# include "combat.hpp"
# include "actorutil.hpp"
namespace
{
@ -56,7 +57,7 @@ void adjustBoundItem (const std::string& item, bool bound, const MWWorld::Ptr& a
action . execute ( actor ) ;
MWWorld : : ContainerStoreIterator rightHand = store . getSlot ( MWWorld : : InventoryStore : : Slot_CarriedRight ) ;
// change draw state only if the item is in player's right hand
if ( actor = = MW Base: : Environment : : get ( ) . getWorld ( ) - > getPlayerPt r( )
if ( actor = = MW Mechanics: : getPlaye r( )
& & rightHand ! = store . end ( ) & & newPtr = = * rightHand )
{
MWBase : : Environment : : get ( ) . getWorld ( ) - > getPlayer ( ) . setDrawState ( MWMechanics : : DrawState_Weapon ) ;
@ -82,7 +83,7 @@ public:
const std : : string & sourceName , const std : : string & sourceId , int casterActorId ,
float magnitude , float remainingTime = - 1 , float totalTime = - 1 )
{
MWWorld : : Ptr player = MW Base: : Environment : : get ( ) . getWorld ( ) - > getPlayerPt r( ) ;
MWWorld : : Ptr player = MW Mechanics: : getPlaye r( ) ;
if ( ( ( key . mId = = ESM : : MagicEffect : : CommandHumanoid & & mActor . getClass ( ) . isNpc ( ) )
| | ( key . mId = = ESM : : MagicEffect : : CommandCreature & & mActor . getTypeName ( ) = = typeid ( ESM : : Creature ) . name ( ) ) )
& & casterActorId = = player . getClass ( ) . getCreatureStats ( player ) . getActorId ( )
@ -203,7 +204,7 @@ namespace MWMechanics
gem - > getContainerStore ( ) - > unstack ( * gem , caster ) ;
gem - > getCellRef ( ) . setSoul ( mCreature . getCellRef ( ) . getRefId ( ) ) ;
if ( caster = = MWBase: : Environment : : get ( ) . getWorld ( ) - > getPlayerPt r( ) )
if ( caster = = getPlayer( ) )
MWBase : : Environment : : get ( ) . getWindowManager ( ) - > messageBox ( " #{sSoultrapSuccess} " ) ;
const ESM : : Static * fx = MWBase : : Environment : : get ( ) . getWorld ( ) - > getStore ( ) . get < ESM : : Static > ( )
@ -401,7 +402,7 @@ namespace MWMechanics
int intelligence = creatureStats . getAttribute ( ESM : : Attribute : : Intelligence ) . getModified ( ) ;
float base = 1.f ;
if ( ptr = = MWBase: : Environment : : get ( ) . getWorld ( ) - > getPlayerPt r( ) )
if ( ptr = = getPlayer( ) )
base = MWBase : : Environment : : get ( ) . getWorld ( ) - > getStore ( ) . get < ESM : : GameSetting > ( ) . find ( " fPCbaseMagickaMult " ) - > getFloat ( ) ;
else
base = MWBase : : Environment : : get ( ) . getWorld ( ) - > getStore ( ) . get < ESM : : GameSetting > ( ) . find ( " fNPCbaseMagickaMult " ) - > getFloat ( ) ;
@ -512,7 +513,7 @@ namespace MWMechanics
{
spells . worsenCorprus ( it - > first ) ;
if ( ptr = = MWBase: : Environment : : get ( ) . getWorld ( ) - > getPlayerPt r( ) )
if ( ptr = = getPlayer( ) )
MWBase : : Environment : : get ( ) . getWindowManager ( ) - > messageBox ( " #{sMagicCorprusWorsens} " ) ;
}
}
@ -539,19 +540,19 @@ namespace MWMechanics
if ( ! creature | | ptr . get < ESM : : Creature > ( ) - > mBase - > mData . mType = = ESM : : Creature : : Creatures )
{
Stat < int > stat = creatureStats . getAiSetting ( CreatureStats : : AI_Fight ) ;
stat . setModifier ( static_cast < int > ( cr eatureStats. getMagicE ffects( ) . get ( ESM : : MagicEffect : : FrenzyHumanoid + creature ) . getMagnitude ( )
- cr eatureStats. getMagicE ffects( ) . get ( ESM : : MagicEffect : : CalmHumanoid + creature ) . getMagnitude ( ) ) ) ;
stat . setModifier ( static_cast < int > ( effects. get ( ESM : : MagicEffect : : FrenzyHumanoid + creature ) . getMagnitude ( )
- effects. get ( ESM : : MagicEffect : : CalmHumanoid + creature ) . getMagnitude ( ) ) ) ;
creatureStats . setAiSetting ( CreatureStats : : AI_Fight , stat ) ;
stat = creatureStats . getAiSetting ( CreatureStats : : AI_Flee ) ;
stat . setModifier ( static_cast < int > ( cr eatureStats. getMagicE ffects( ) . get ( ESM : : MagicEffect : : DemoralizeHumanoid + creature ) . getMagnitude ( )
- cr eatureStats. getMagicE ffects( ) . get ( ESM : : MagicEffect : : RallyHumanoid + creature ) . getMagnitude ( ) ) ) ;
stat . setModifier ( static_cast < int > ( effects. get ( ESM : : MagicEffect : : DemoralizeHumanoid + creature ) . getMagnitude ( )
- effects. get ( ESM : : MagicEffect : : RallyHumanoid + creature ) . getMagnitude ( ) ) ) ;
creatureStats . setAiSetting ( CreatureStats : : AI_Flee , stat ) ;
}
if ( creature & & ptr . get < ESM : : Creature > ( ) - > mBase - > mData . mType = = ESM : : Creature : : Undead )
{
Stat < int > stat = creatureStats . getAiSetting ( CreatureStats : : AI_Flee ) ;
stat . setModifier ( static_cast < int > ( cr eatureStats. getMagicE ffects( ) . get ( ESM : : MagicEffect : : TurnUndead ) . getMagnitude ( ) ) ) ;
stat . setModifier ( static_cast < int > ( effects. get ( ESM : : MagicEffect : : TurnUndead ) . getMagnitude ( ) ) ) ;
creatureStats . setAiSetting ( CreatureStats : : AI_Flee , stat ) ;
}
@ -560,7 +561,7 @@ namespace MWMechanics
// The actor was killed by a magic effect. Figure out if the player was responsible for it.
const ActiveSpells & spells = creatureStats . getActiveSpells ( ) ;
bool killedByPlayer = false ;
MWWorld : : Ptr player = MWBase: : Environment : : get ( ) . getWorld ( ) - > getPlayerPt r( ) ;
MWWorld : : Ptr player = getPlayer( ) ;
for ( ActiveSpells : : TIterator it = spells . begin ( ) ; it ! = spells . end ( ) ; + + it )
{
const ActiveSpells : : ActiveSpellParams & spell = it - > second ;
@ -597,8 +598,8 @@ namespace MWMechanics
// TODO: dirty flag for magic effects to avoid some unnecessary work below?
// any value of calm > 0 will stop the actor from fighting
if ( ( cr eatureStats. getMagicE ffects( ) . get ( ESM : : MagicEffect : : CalmHumanoid ) . getMagnitude ( ) > 0 & & ptr . getClass ( ) . isNpc ( ) )
| | ( cr eatureStats. getMagicE ffects( ) . get ( ESM : : MagicEffect : : CalmCreature ) . getMagnitude ( ) > 0 & & ! ptr . getClass ( ) . isNpc ( ) ) )
if ( ( effects. get ( ESM : : MagicEffect : : CalmHumanoid ) . getMagnitude ( ) > 0 & & ptr . getClass ( ) . isNpc ( ) )
| | ( effects. get ( ESM : : MagicEffect : : CalmCreature ) . getMagnitude ( ) > 0 & & ! ptr . getClass ( ) . isNpc ( ) ) )
{
for ( std : : list < AiPackage * > : : const_iterator it = creatureStats . getAiSequence ( ) . begin ( ) ; it ! = creatureStats . getAiSequence ( ) . end ( ) ; )
{
@ -631,7 +632,7 @@ namespace MWMechanics
for ( std : : map < int , std : : string > : : iterator it = boundItemsMap . begin ( ) ; it ! = boundItemsMap . end ( ) ; + + it )
{
bool found = creatureStats . mBoundItems . find ( it - > first ) ! = creatureStats . mBoundItems . end ( ) ;
float magnitude = cr eatureStats. getMagicE ffects( ) . get ( it - > first ) . getMagnitude ( ) ;
float magnitude = effects. get ( it - > first ) . getMagnitude ( ) ;
if ( found ! = ( magnitude > 0 ) )
{
std : : string itemGmst = it - > second ;
@ -727,7 +728,7 @@ namespace MWMechanics
void Actors : : updateEquippedLight ( const MWWorld : : Ptr & ptr , float duration )
{
bool isPlayer = ( ptr = = MWBase: : Environment : : get ( ) . getWorld ( ) - > getPlayerPt r( ) ) ;
bool isPlayer = ( ptr = = getPlayer( ) ) ;
MWWorld : : InventoryStore & inventoryStore = ptr . getClass ( ) . getInventoryStore ( ptr ) ;
MWWorld : : ContainerStoreIterator heldIter =
@ -824,7 +825,7 @@ namespace MWMechanics
void Actors : : updateCrimePersuit ( const MWWorld : : Ptr & ptr , float duration )
{
MWWorld : : Ptr player = MWBase: : Environment : : get ( ) . getWorld ( ) - > getPlayerPt r( ) ;
MWWorld : : Ptr player = getPlayer( ) ;
if ( ptr ! = player & & ptr . getClass ( ) . isNpc ( ) )
{
// get stats of witness
@ -946,7 +947,7 @@ namespace MWMechanics
if ( timerUpdateAITargets > = 1.0f ) timerUpdateAITargets = 0 ;
if ( timerUpdateHeadTrack > = 0.3f ) timerUpdateHeadTrack = 0 ;
MWWorld : : Ptr player = MWBase: : Environment : : get ( ) . getWorld ( ) - > getPlayerPt r( ) ;
MWWorld : : Ptr player = getPlayer( ) ;
int hostilesCount = 0 ; // need to know this to play Battle music
@ -1038,13 +1039,12 @@ namespace MWMechanics
> sqrProcessingDistance )
continue ;
if ( iter - > first . getClass ( ) . getCreatureStats ( iter - > first ) . getMagicEffects ( ) . get (
ESM : : MagicEffect : : Paralyze ) . getMagnitude ( ) > 0 )
if ( iter - > first . getClass ( ) . getCreatureStats ( iter - > first ) . isParalyzed ( ) )
iter - > second - > getCharacterController ( ) - > skipAnim ( ) ;
// Handle player last, in case a cell transition occurs by casting a teleportation spell
// (would invalidate the iterator)
if ( iter - > first = = MWBase: : Environment : : get ( ) . getWorld ( ) - > getPlayerPt r( ) )
if ( iter - > first = = getPlayer( ) )
{
playerCharacter = iter - > second - > getCharacterController ( ) ;
continue ;
@ -1431,9 +1431,9 @@ namespace MWMechanics
for ( PtrActorMap : : iterator it = map . begin ( ) ; it ! = map . end ( ) ; + + it )
{
MWWorld : : Ptr ptr = it - > first ;
if ( ptr = = MWBase: : Environment : : get ( ) . getWorld ( ) - > getPlayerPt r( )
if ( ptr = = getPlayer( )
| | ! isConscious ( ptr )
| | ptr . getClass ( ) . getCreatureStats ( ptr ) . getMag icEffect s( ) . get ( ESM : : MagicEffect : : Paralyze) . getMagnitu de ( ) > 0 )
| | ptr . getClass ( ) . getCreatureStats ( ptr ) . isParalyzed( ) )
continue ;
MWMechanics : : AiSequence & seq = ptr . getClass ( ) . getCreatureStats ( ptr ) . getAiSequence ( ) ;
seq . fastForward ( ptr , it - > second - > getAiState ( ) ) ;