Added witnesses to the mix

actorid
Jeffrey Haines 11 years ago
parent b1abef7a38
commit 0c957a3cde

@ -719,9 +719,9 @@ namespace MWMechanics
void Actors::updateCrimePersuit(const MWWorld::Ptr& ptr, float duration)
{
MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayerPtr();
int bounty = player.getClass().getNpcStats(player).getBounty();
CreatureStats& creatureStats = MWWorld::Class::get(ptr).getCreatureStats(ptr);
// TODO: Move me! I shouldn't be here...
/// \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()) *
@ -729,30 +729,40 @@ namespace MWMechanics
if (ptr != player)
{
CreatureStats& creatureStats = MWWorld::Class::get(ptr).getCreatureStats(ptr);
// Alarmed or not, I will kill you because you've commited heinous against the empire
if ((!creatureStats.isAlarmed() || creatureStats.isAlarmed()) &&
ptr.getClass().isClass(ptr, "Guard") && bounty >= cutoff && !creatureStats.isHostile())
creatureStats.getAiSequence().stack(AiPersue(player.getClass().getId(player)));
else if (creatureStats.isAlarmed())
// If I'm a guard and I'm not hostile
if (ptr.getClass().isClass(ptr, "Guard") && !creatureStats.isHostile())
{
// Attack on sight if bounty is greater than the cutoff
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(player));
creatureStats.setHostile(true);
}
}
// if I was a witness to a crime
if (creatureStats.getCrimeId() != -1)
{
MWBase::Environment::get().getDialogueManager()->say(ptr, "Thief");
if(bounty == 0)
if(player.getClass().getNpcStats(player).getBounty() == 0)
{
creatureStats.setAlarmed(false);
creatureStats.setHostile(false);
if (ptr.getClass().isClass(ptr, "Guard"))
creatureStats.getAiSequence().stopPersue();
creatureStats.getAiSequence().stopCombat();
creatureStats.setCrimeId(-1);
}
if (ptr.getClass().isClass(ptr, "Guard") && !creatureStats.isHostile())
creatureStats.getAiSequence().stack(AiPersue(player.getClass().getId(player)));
else if (!creatureStats.isHostile())
else if (creatureStats.isAlarmed())
{
creatureStats.getAiSequence().stack(AiCombat(player));
creatureStats.setHostile(true);
if (ptr.getClass().isClass(ptr, "Guard") && !creatureStats.isHostile())
creatureStats.getAiSequence().stack(AiPersue(player.getClass().getId(player)));
else if (!creatureStats.isHostile())
{
creatureStats.getAiSequence().stack(AiCombat(player));
creatureStats.setHostile(true);
}
}
}
}

@ -15,7 +15,7 @@ namespace MWMechanics
: mLevel (0), mDead (false), mDied (false), mFriendlyHits (0),
mTalkedTo (false), mAlarmed (false),
mAttacked (false), mHostile (false), mAssaulted(false),
mAttackingOrSpell(false),
mAttackingOrSpell(false), mCrimeId(-1),
mIsWerewolf(false),
mFallHeight(0), mRecalcDynamicStats(false), mKnockdown(false), mHitRecovery(false), mBlock(false),
mMovementFlags(0), mDrawState (DrawState_Nothing), mAttackStrength(0.f)
@ -326,6 +326,16 @@ namespace MWMechanics
mAssaulted = assaulted;
}
int CreatureStats::getCrimeId() const
{
return mCrimeId;
}
void CreatureStats::setCrimeId (int id)
{
mCrimeId = id;
}
bool CreatureStats::getCreatureTargetted() const
{
std::string target;

@ -40,6 +40,7 @@ namespace MWMechanics
bool mAttacked;
bool mHostile;
bool mAssaulted;
int mCrimeId;
bool mAttackingOrSpell;
bool mKnockdown;
bool mHitRecovery;
@ -191,6 +192,10 @@ namespace MWMechanics
void setAssaulted (bool assaulted);
int getCrimeId() const;
void setCrimeId (int id);
bool getCreatureTargetted() const;
float getEvasion() const;

@ -810,6 +810,7 @@ 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;
@ -858,13 +859,19 @@ namespace MWMechanics
if (*it1 == ptr) // Not the player
continue;
// was the witness alarmed?
// Will the witness be affected by the crime?
CreatureStats& creatureStats1 = MWWorld::Class::get(*it1).getCreatureStats(*it1);
if (creatureStats1.getAiSetting(CreatureStats::AI_Alarm).getBase() >= alarm)
{
creatureStats1.setAlarmed(true);
creatureStats1.setCrimeId(player.getWitnessTotal());
player.addWitness();
}
}
break; // Someone saw the crime and everyone has been told
}
}
else if (type == OT_Assault)
creatureStats.setAlarmed(true);
}
}
if (reported)

@ -28,8 +28,9 @@ namespace MWWorld
: mCellStore(0),
mLastKnownExteriorPosition(0,0,0),
mAutoMove(false),
mForwardBackward (0),
mForwardBackward(0),
mTeleported(false),
mWitnessTotal(0),
mMarkedCell(NULL)
{
mPlayer.mBase = player;
@ -65,6 +66,16 @@ namespace MWWorld
return mSign;
}
void Player::addWitness()
{
mWitnessTotal++;
}
int Player::getWitnessTotal() const
{
return mWitnessTotal;
}
void Player::setDrawState (MWMechanics::DrawState_ state)
{
MWWorld::Ptr ptr = getPlayer();

@ -41,6 +41,8 @@ namespace MWWorld
bool mAutoMove;
int mForwardBackward;
bool mTeleported;
int mWitnessTotal;
public:
@ -65,6 +67,10 @@ namespace MWWorld
void setBirthSign(const std::string &sign);
void addWitness();
int getWitnessTotal() const;
const std::string &getBirthSign() const;
void setDrawState (MWMechanics::DrawState_ state);

Loading…
Cancel
Save