diff --git a/apps/openmw/mwmechanics/actors.cpp b/apps/openmw/mwmechanics/actors.cpp index ee30dae6d..ca37b152c 100644 --- a/apps/openmw/mwmechanics/actors.cpp +++ b/apps/openmw/mwmechanics/actors.cpp @@ -716,13 +716,12 @@ namespace MWMechanics void Actors::updateCrimePersuit(const MWWorld::Ptr& ptr, float duration) { - MWWorld::Ptr playerPtr = MWBase::Environment::get().getWorld()->getPlayerPtr(); - if (ptr != playerPtr) + MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayerPtr(); + if (ptr != player && ptr.getClass().isNpc()) { // get stats of witness CreatureStats& creatureStats = MWWorld::Class::get(ptr).getCreatureStats(ptr); NpcStats& npcStats = MWWorld::Class::get(ptr).getNpcStats(ptr); - MWWorld::Player player = MWBase::Environment::get().getWorld()->getPlayer(); // If I'm a guard and I'm not hostile if (ptr.getClass().isClass(ptr, "Guard") && !creatureStats.isHostile()) @@ -733,13 +732,13 @@ namespace MWMechanics float(esmStore.get().find("iCrimeThresholdMultiplier")->getInt()) * esmStore.get().find("fCrimeGoldDiscountMult")->getFloat(); // Attack on sight if bounty is greater than the cutoff - if ( playerPtr.getClass().getNpcStats(playerPtr).getBounty() >= cutoff - && MWBase::Environment::get().getWorld()->getLOS(ptr, playerPtr) - && MWBase::Environment::get().getMechanicsManager()->awarenessCheck(playerPtr, ptr)) + if ( player.getClass().getNpcStats(player).getBounty() >= cutoff + && MWBase::Environment::get().getWorld()->getLOS(ptr, player) + && MWBase::Environment::get().getMechanicsManager()->awarenessCheck(player, ptr)) { - creatureStats.getAiSequence().stack(AiCombat(playerPtr)); + creatureStats.getAiSequence().stack(AiCombat(player)); creatureStats.setHostile(true); - npcStats.setCrimeId(player.getNewCrimeId()); + npcStats.setCrimeId( MWBase::Environment::get().getWorld()->getPlayer().getCrimeId() ); } } @@ -747,7 +746,7 @@ namespace MWMechanics if (npcStats.getCrimeId() != -1) { // if you've payed for your crimes and I havent noticed - if(npcStats.getCrimeId() < player.getCrimeId() ) + if( npcStats.getCrimeId() <= MWBase::Environment::get().getWorld()->getPlayer().getCrimeId() ) { // Calm witness down if (ptr.getClass().isClass(ptr, "Guard")) @@ -765,9 +764,9 @@ namespace MWMechanics else if (!creatureStats.isHostile()) { if (ptr.getClass().isClass(ptr, "Guard")) - creatureStats.getAiSequence().stack(AiPersue(playerPtr.getClass().getId(playerPtr))); + creatureStats.getAiSequence().stack(AiPersue(player.getClass().getId(player))); else - creatureStats.getAiSequence().stack(AiCombat(playerPtr)); + creatureStats.getAiSequence().stack(AiCombat(player)); creatureStats.setHostile(true); } } @@ -775,7 +774,7 @@ namespace MWMechanics // if I didn't report a crime was I attacked? else if (creatureStats.getAttacked() && !creatureStats.isHostile()) { - creatureStats.getAiSequence().stack(AiCombat(playerPtr)); + creatureStats.getAiSequence().stack(AiCombat(player)); creatureStats.setHostile(true); } } diff --git a/apps/openmw/mwmechanics/mechanicsmanagerimp.cpp b/apps/openmw/mwmechanics/mechanicsmanagerimp.cpp index a26520fc7..d162e1037 100644 --- a/apps/openmw/mwmechanics/mechanicsmanagerimp.cpp +++ b/apps/openmw/mwmechanics/mechanicsmanagerimp.cpp @@ -810,7 +810,6 @@ namespace MWMechanics return false; const MWWorld::ESMStore& esmStore = MWBase::Environment::get().getWorld()->getStore(); - MWWorld::Player player = MWBase::Environment::get().getWorld()->getPlayer(); // What amount of alarm did this crime generate? int alarm; @@ -842,22 +841,23 @@ namespace MWMechanics if ( ( MWBase::Environment::get().getWorld()->getLOS(ptr, *it) && awarenessCheck(ptr, *it) ) || type == OT_Assault ) { - // TODO: Add more messages - if (type == OT_Theft) - MWBase::Environment::get().getDialogueManager()->say(*it, "thief"); - else if (type == OT_Assault) - MWBase::Environment::get().getDialogueManager()->say(*it, "attack"); // Will the witness report the crime? if (it->getClass().getCreatureStats(*it).getAiSetting(CreatureStats::AI_Alarm).getBase() >= alarm) { reported = true; - int id = player.getNewCrimeId(); + int id = MWBase::Environment::get().getWorld()->getPlayer().getNewCrimeId(); // Tell everyone, including yourself for (std::vector::iterator it1 = neighbors.begin(); it1 != neighbors.end(); ++it1) { if (*it1 == ptr) continue; // not the player + + // TODO: Add more messages + if (type == OT_Theft) + MWBase::Environment::get().getDialogueManager()->say(*it1, "thief"); + else if (type == OT_Assault) + MWBase::Environment::get().getDialogueManager()->say(*it1, "attack"); // Will other witnesses paticipate in crime if ( it1->getClass().getCreatureStats(*it1).getAiSetting(CreatureStats::AI_Alarm).getBase() >= alarm diff --git a/apps/openmw/mwworld/player.cpp b/apps/openmw/mwworld/player.cpp index d39ec2c0f..e8179b9f3 100644 --- a/apps/openmw/mwworld/player.cpp +++ b/apps/openmw/mwworld/player.cpp @@ -279,7 +279,7 @@ namespace MWWorld int Player::getNewCrimeId() { - return mCurrentCrimeId++; + return ++mCurrentCrimeId; } void Player::recordCrimeId() @@ -289,6 +289,6 @@ namespace MWWorld int Player::getCrimeId() const { - return mCurrentCrimeId; + return mPayedCrimeId; } } diff --git a/components/esm/npcstats.cpp b/components/esm/npcstats.cpp index 531424ab2..80238ad68 100644 --- a/components/esm/npcstats.cpp +++ b/components/esm/npcstats.cpp @@ -67,6 +67,9 @@ void ESM::NpcStats::load (ESMReader &esm) mLevelHealthBonus = 0; esm.getHNOT (mLevelHealthBonus, "LVLH"); + + mCrimeId = -1; + esm.getHNOT (mCrimeId, "CRID"); } void ESM::NpcStats::save (ESMWriter &esm) const @@ -130,4 +133,7 @@ void ESM::NpcStats::save (ESMWriter &esm) const if (mLevelHealthBonus) esm.writeHNT ("LVLH", mLevelHealthBonus); + + if (mCrimeId != -1) + esm.writeHNT ("CRID", mCrimeId); } \ No newline at end of file diff --git a/components/esm/npcstats.hpp b/components/esm/npcstats.hpp index b3f70db25..504cd0163 100644 --- a/components/esm/npcstats.hpp +++ b/components/esm/npcstats.hpp @@ -45,6 +45,7 @@ namespace ESM float mTimeToStartDrowning; float mLastDrowningHit; float mLevelHealthBonus; + int mCrimeId; void load (ESMReader &esm); void save (ESMWriter &esm) const; diff --git a/components/esm/player.cpp b/components/esm/player.cpp index d5ddc74d0..e41cc535e 100644 --- a/components/esm/player.cpp +++ b/components/esm/player.cpp @@ -25,6 +25,9 @@ void ESM::Player::load (ESMReader &esm) esm.getHNOT (mAutoMove, "AMOV"); mBirthsign = esm.getHNString ("SIGN"); + + esm.getHNT (mCurrentCrimeId, "CURD"); + esm.getHNT (mPayedCrimeId, "PAYD"); } void ESM::Player::save (ESMWriter &esm) const @@ -45,4 +48,7 @@ void ESM::Player::save (ESMWriter &esm) const esm.writeHNT ("AMOV", mAutoMove); esm.writeHNString ("SIGN", mBirthsign); + + esm.writeHNT ("CURD", mCurrentCrimeId); + esm.writeHNT ("PAYD", mPayedCrimeId); } \ No newline at end of file diff --git a/components/esm/player.hpp b/components/esm/player.hpp index 0d70ee090..377c8547a 100644 --- a/components/esm/player.hpp +++ b/components/esm/player.hpp @@ -24,6 +24,9 @@ namespace ESM CellId mMarkedCell; unsigned char mAutoMove; std::string mBirthsign; + + int mCurrentCrimeId; + int mPayedCrimeId; void load (ESMReader &esm); void save (ESMWriter &esm) const;