States are saved. Crime is reacted to.

Issues where some crime is ignored. Needs a lot more work
actorid
Jeffrey Haines 11 years ago
parent 940c88d2ec
commit a274b48f2f

@ -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<ESM::GameSetting>().find("iCrimeThresholdMultiplier")->getInt()) *
esmStore.get<ESM::GameSetting>().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);
}
}

@ -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<MWWorld::Ptr>::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

@ -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;
}
}

@ -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);
}

@ -45,6 +45,7 @@ namespace ESM
float mTimeToStartDrowning;
float mLastDrowningHit;
float mLevelHealthBonus;
int mCrimeId;
void load (ESMReader &esm);
void save (ESMWriter &esm) const;

@ -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);
}

@ -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;

Loading…
Cancel
Save