@ -29,7 +29,7 @@
# include "aicombat.hpp"
# include "aifollow.hpp"
# include "aip e rsue.hpp"
# include "aip u rsue.hpp"
namespace
{
@ -719,34 +719,33 @@ namespace MWMechanics
CreatureStats & creatureStats = MWWorld : : Class : : get ( ptr ) . getCreatureStats ( ptr ) ;
NpcStats & npcStats = MWWorld : : Class : : get ( ptr ) . getNpcStats ( ptr ) ;
// If I'm a guard and I'm not hostile
if ( ptr . getClass ( ) . isClass ( ptr , " Guard " ) & & ! creatureStats . isHostile ( ) )
if ( ptr . getClass ( ) . isClass ( ptr , " Guard " ) & & creatureStats . getAiSequence ( ) . getTypeId ( ) ! = AiPackage : : TypeIdPursue & & ! creatureStats . isHostile ( ) )
{
/// \todo Move me! I shouldn't be here...
const MWWorld : : ESMStore & esmStore = MWBase : : Environment : : get ( ) . getWorld ( ) - > getStore ( ) ;
float cutoff = float ( esmStore . get < ESM : : GameSetting > ( ) . find ( " iCrimeThreshold " ) - > getInt ( ) ) *
float ( esmStore . get < ESM : : GameSetting > ( ) . find ( " iCrimeThresholdMultiplier " ) - > getInt ( ) ) *
esmStore . get < ESM : : GameSetting > ( ) . find ( " fCrimeGoldDiscountMult " ) - > getFloat ( ) ;
// Attack on sight if bounty is greater than the cutoff
float cutoff = float ( esmStore . get < ESM : : GameSetting > ( ) . find ( " iCrimeThreshold " ) - > getInt ( ) ) ;
// Force dialogue on sight if bounty is greater than the cutoff
// In vanilla morrowind, the greeting dialogue is scripted to either arrest the player (< 5000 bounty) or attack (>= 5000 bounty)
if ( player . getClass ( ) . getNpcStats ( player ) . getBounty ( ) > = cutoff
// TODO: do not run these two every frame. keep an Aware state for each actor and update it every 0.2 s or so?
& & MWBase : : Environment : : get ( ) . getWorld ( ) - > getLOS ( ptr , player )
& & MWBase : : Environment : : get ( ) . getMechanicsManager ( ) - > awarenessCheck ( player , ptr ) )
{
creatureStats . getAiSequence ( ) . stack ( Ai Combat( player ) , ptr ) ;
creatureStats . set Hostile ( true ) ;
npcStats . setCrimeId ( MWBase : : Environment : : get ( ) . getWorld ( ) - > getPlayer ( ) . get CrimeId( ) ) ;
creatureStats . getAiSequence ( ) . stack ( Ai Pursue( player . getClass ( ) . getId ( player ) ) , ptr ) ;
creatureStats . set Alarmed ( true ) ;
npcStats . setCrimeId ( MWBase : : Environment : : get ( ) . getWorld ( ) - > getPlayer ( ) . get New CrimeId( ) ) ;
}
}
// if I was a witness to a crime
if ( npcStats . getCrimeId ( ) ! = - 1 )
{
// if you've pa ye d for your crimes and I havent noticed
// if you've pa i d for your crimes and I havent noticed
if ( npcStats . getCrimeId ( ) < = MWBase : : Environment : : get ( ) . getWorld ( ) - > getPlayer ( ) . getCrimeId ( ) )
{
// Calm witness down
if ( ptr . getClass ( ) . isClass ( ptr , " Guard " ) )
creatureStats . getAiSequence ( ) . stopP ersue ( ) ;
creatureStats . getAiSequence ( ) . stopP ursuit ( ) ;
creatureStats . getAiSequence ( ) . stopCombat ( ) ;
// Reset factors to attack
@ -761,13 +760,12 @@ namespace MWMechanics
else if ( ! creatureStats . isHostile ( ) )
{
if ( ptr . getClass ( ) . isClass ( ptr , " Guard " ) )
creatureStats . getAiSequence ( ) . stack ( AiP e rsue( player . getClass ( ) . getId ( player ) ) , ptr ) ;
creatureStats . getAiSequence ( ) . stack ( AiP u rsue( player . getClass ( ) . getId ( player ) ) , ptr ) ;
else
creatureStats . getAiSequence ( ) . stack ( AiCombat ( player ) , ptr ) ;
creatureStats . setHostile ( true ) ;
}
}
// if I didn't report a crime was I attacked?
else if ( creatureStats . getAttacked ( ) & & ! creatureStats . isHostile ( ) )
{