mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-19 21:53:51 +00:00
Added witnesses to the mix
This commit is contained in:
parent
b1abef7a38
commit
0c957a3cde
6 changed files with 70 additions and 21 deletions
|
@ -719,9 +719,9 @@ namespace MWMechanics
|
||||||
void Actors::updateCrimePersuit(const MWWorld::Ptr& ptr, float duration)
|
void Actors::updateCrimePersuit(const MWWorld::Ptr& ptr, float duration)
|
||||||
{
|
{
|
||||||
MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayerPtr();
|
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();
|
const MWWorld::ESMStore& esmStore = MWBase::Environment::get().getWorld()->getStore();
|
||||||
float cutoff = float(esmStore.get<ESM::GameSetting>().find("iCrimeThreshold")->getInt()) *
|
float cutoff = float(esmStore.get<ESM::GameSetting>().find("iCrimeThreshold")->getInt()) *
|
||||||
float(esmStore.get<ESM::GameSetting>().find("iCrimeThresholdMultiplier")->getInt()) *
|
float(esmStore.get<ESM::GameSetting>().find("iCrimeThresholdMultiplier")->getInt()) *
|
||||||
|
@ -729,30 +729,40 @@ namespace MWMechanics
|
||||||
|
|
||||||
if (ptr != player)
|
if (ptr != player)
|
||||||
{
|
{
|
||||||
CreatureStats& creatureStats = MWWorld::Class::get(ptr).getCreatureStats(ptr);
|
// If I'm a guard and I'm not hostile
|
||||||
// Alarmed or not, I will kill you because you've commited heinous against the empire
|
if (ptr.getClass().isClass(ptr, "Guard") && !creatureStats.isHostile())
|
||||||
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())
|
|
||||||
{
|
{
|
||||||
MWBase::Environment::get().getDialogueManager()->say(ptr, "Thief");
|
// Attack on sight if bounty is greater than the cutoff
|
||||||
if(bounty == 0)
|
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)
|
||||||
|
{
|
||||||
|
if(player.getClass().getNpcStats(player).getBounty() == 0)
|
||||||
{
|
{
|
||||||
creatureStats.setAlarmed(false);
|
creatureStats.setAlarmed(false);
|
||||||
creatureStats.setHostile(false);
|
creatureStats.setHostile(false);
|
||||||
if (ptr.getClass().isClass(ptr, "Guard"))
|
if (ptr.getClass().isClass(ptr, "Guard"))
|
||||||
creatureStats.getAiSequence().stopPersue();
|
creatureStats.getAiSequence().stopPersue();
|
||||||
creatureStats.getAiSequence().stopCombat();
|
creatureStats.getAiSequence().stopCombat();
|
||||||
|
creatureStats.setCrimeId(-1);
|
||||||
}
|
}
|
||||||
|
else if (creatureStats.isAlarmed())
|
||||||
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));
|
if (ptr.getClass().isClass(ptr, "Guard") && !creatureStats.isHostile())
|
||||||
creatureStats.setHostile(true);
|
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),
|
: mLevel (0), mDead (false), mDied (false), mFriendlyHits (0),
|
||||||
mTalkedTo (false), mAlarmed (false),
|
mTalkedTo (false), mAlarmed (false),
|
||||||
mAttacked (false), mHostile (false), mAssaulted(false),
|
mAttacked (false), mHostile (false), mAssaulted(false),
|
||||||
mAttackingOrSpell(false),
|
mAttackingOrSpell(false), mCrimeId(-1),
|
||||||
mIsWerewolf(false),
|
mIsWerewolf(false),
|
||||||
mFallHeight(0), mRecalcDynamicStats(false), mKnockdown(false), mHitRecovery(false), mBlock(false),
|
mFallHeight(0), mRecalcDynamicStats(false), mKnockdown(false), mHitRecovery(false), mBlock(false),
|
||||||
mMovementFlags(0), mDrawState (DrawState_Nothing), mAttackStrength(0.f)
|
mMovementFlags(0), mDrawState (DrawState_Nothing), mAttackStrength(0.f)
|
||||||
|
@ -326,6 +326,16 @@ namespace MWMechanics
|
||||||
mAssaulted = assaulted;
|
mAssaulted = assaulted;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int CreatureStats::getCrimeId() const
|
||||||
|
{
|
||||||
|
return mCrimeId;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CreatureStats::setCrimeId (int id)
|
||||||
|
{
|
||||||
|
mCrimeId = id;
|
||||||
|
}
|
||||||
|
|
||||||
bool CreatureStats::getCreatureTargetted() const
|
bool CreatureStats::getCreatureTargetted() const
|
||||||
{
|
{
|
||||||
std::string target;
|
std::string target;
|
||||||
|
|
|
@ -40,6 +40,7 @@ namespace MWMechanics
|
||||||
bool mAttacked;
|
bool mAttacked;
|
||||||
bool mHostile;
|
bool mHostile;
|
||||||
bool mAssaulted;
|
bool mAssaulted;
|
||||||
|
int mCrimeId;
|
||||||
bool mAttackingOrSpell;
|
bool mAttackingOrSpell;
|
||||||
bool mKnockdown;
|
bool mKnockdown;
|
||||||
bool mHitRecovery;
|
bool mHitRecovery;
|
||||||
|
@ -191,6 +192,10 @@ namespace MWMechanics
|
||||||
|
|
||||||
void setAssaulted (bool assaulted);
|
void setAssaulted (bool assaulted);
|
||||||
|
|
||||||
|
int getCrimeId() const;
|
||||||
|
|
||||||
|
void setCrimeId (int id);
|
||||||
|
|
||||||
bool getCreatureTargetted() const;
|
bool getCreatureTargetted() const;
|
||||||
|
|
||||||
float getEvasion() const;
|
float getEvasion() const;
|
||||||
|
|
|
@ -810,6 +810,7 @@ namespace MWMechanics
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
const MWWorld::ESMStore& esmStore = MWBase::Environment::get().getWorld()->getStore();
|
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?
|
// What amount of alarm did this crime generate?
|
||||||
int alarm;
|
int alarm;
|
||||||
|
@ -858,13 +859,19 @@ namespace MWMechanics
|
||||||
if (*it1 == ptr) // Not the player
|
if (*it1 == ptr) // Not the player
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
// was the witness alarmed?
|
// Will the witness be affected by the crime?
|
||||||
CreatureStats& creatureStats1 = MWWorld::Class::get(*it1).getCreatureStats(*it1);
|
CreatureStats& creatureStats1 = MWWorld::Class::get(*it1).getCreatureStats(*it1);
|
||||||
if (creatureStats1.getAiSetting(CreatureStats::AI_Alarm).getBase() >= alarm)
|
if (creatureStats1.getAiSetting(CreatureStats::AI_Alarm).getBase() >= alarm)
|
||||||
|
{
|
||||||
creatureStats1.setAlarmed(true);
|
creatureStats1.setAlarmed(true);
|
||||||
|
creatureStats1.setCrimeId(player.getWitnessTotal());
|
||||||
|
player.addWitness();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
break; // Someone saw the crime and everyone has been told
|
break; // Someone saw the crime and everyone has been told
|
||||||
}
|
}
|
||||||
|
else if (type == OT_Assault)
|
||||||
|
creatureStats.setAlarmed(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (reported)
|
if (reported)
|
||||||
|
|
|
@ -28,8 +28,9 @@ namespace MWWorld
|
||||||
: mCellStore(0),
|
: mCellStore(0),
|
||||||
mLastKnownExteriorPosition(0,0,0),
|
mLastKnownExteriorPosition(0,0,0),
|
||||||
mAutoMove(false),
|
mAutoMove(false),
|
||||||
mForwardBackward (0),
|
mForwardBackward(0),
|
||||||
mTeleported(false),
|
mTeleported(false),
|
||||||
|
mWitnessTotal(0),
|
||||||
mMarkedCell(NULL)
|
mMarkedCell(NULL)
|
||||||
{
|
{
|
||||||
mPlayer.mBase = player;
|
mPlayer.mBase = player;
|
||||||
|
@ -65,6 +66,16 @@ namespace MWWorld
|
||||||
return mSign;
|
return mSign;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Player::addWitness()
|
||||||
|
{
|
||||||
|
mWitnessTotal++;
|
||||||
|
}
|
||||||
|
|
||||||
|
int Player::getWitnessTotal() const
|
||||||
|
{
|
||||||
|
return mWitnessTotal;
|
||||||
|
}
|
||||||
|
|
||||||
void Player::setDrawState (MWMechanics::DrawState_ state)
|
void Player::setDrawState (MWMechanics::DrawState_ state)
|
||||||
{
|
{
|
||||||
MWWorld::Ptr ptr = getPlayer();
|
MWWorld::Ptr ptr = getPlayer();
|
||||||
|
|
|
@ -42,6 +42,8 @@ namespace MWWorld
|
||||||
int mForwardBackward;
|
int mForwardBackward;
|
||||||
bool mTeleported;
|
bool mTeleported;
|
||||||
|
|
||||||
|
int mWitnessTotal;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
Player(const ESM::NPC *player, const MWBase::World& world);
|
Player(const ESM::NPC *player, const MWBase::World& world);
|
||||||
|
@ -65,6 +67,10 @@ namespace MWWorld
|
||||||
|
|
||||||
void setBirthSign(const std::string &sign);
|
void setBirthSign(const std::string &sign);
|
||||||
|
|
||||||
|
void addWitness();
|
||||||
|
|
||||||
|
int getWitnessTotal() const;
|
||||||
|
|
||||||
const std::string &getBirthSign() const;
|
const std::string &getBirthSign() const;
|
||||||
|
|
||||||
void setDrawState (MWMechanics::DrawState_ state);
|
void setDrawState (MWMechanics::DrawState_ state);
|
||||||
|
|
Loading…
Reference in a new issue