forked from teamnwah/openmw-tes3coop
Crime: improvement to arrest on sight for large bounties
iCrimeThreshold controls the needed bounty to have guards run to the player and force dialogue. In vanilla, the greeting dialogue is scripted to either arrest the player (< 5000 bounty) or present a death sentence and attack (>= 5000 bounty).
This commit is contained in:
parent
7331a64e34
commit
122e606e30
3 changed files with 18 additions and 15 deletions
|
@ -719,22 +719,21 @@ namespace MWMechanics
|
||||||
CreatureStats& creatureStats = MWWorld::Class::get(ptr).getCreatureStats(ptr);
|
CreatureStats& creatureStats = MWWorld::Class::get(ptr).getCreatureStats(ptr);
|
||||||
NpcStats& npcStats = MWWorld::Class::get(ptr).getNpcStats(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.getAiSequence().getTypeId() != AiPackage::TypeIdPersue && !creatureStats.isHostile())
|
||||||
if (ptr.getClass().isClass(ptr, "Guard") && !creatureStats.isHostile())
|
|
||||||
{
|
{
|
||||||
/// \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()) *
|
// Force dialogue on sight if bounty is greater than the cutoff
|
||||||
esmStore.get<ESM::GameSetting>().find("fCrimeGoldDiscountMult")->getFloat();
|
// In vanilla morrowind, the greeting dialogue is scripted to either arrest the player (< 5000 bounty) or attack (>= 5000 bounty)
|
||||||
// Attack on sight if bounty is greater than the cutoff
|
|
||||||
if ( player.getClass().getNpcStats(player).getBounty() >= cutoff
|
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().getWorld()->getLOS(ptr, player)
|
||||||
&& MWBase::Environment::get().getMechanicsManager()->awarenessCheck(player, ptr))
|
&& MWBase::Environment::get().getMechanicsManager()->awarenessCheck(player, ptr))
|
||||||
{
|
{
|
||||||
creatureStats.getAiSequence().stack(AiCombat(player), ptr);
|
creatureStats.getAiSequence().stack(AiPersue(player.getClass().getId(player)), ptr);
|
||||||
creatureStats.setHostile(true);
|
creatureStats.setAlarmed(true);
|
||||||
npcStats.setCrimeId( MWBase::Environment::get().getWorld()->getPlayer().getCrimeId() );
|
npcStats.setCrimeId(MWBase::Environment::get().getWorld()->getPlayer().getNewCrimeId());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -767,7 +766,6 @@ namespace MWMechanics
|
||||||
creatureStats.setHostile(true);
|
creatureStats.setHostile(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// if I didn't report a crime was I attacked?
|
// if I didn't report a crime was I attacked?
|
||||||
else if (creatureStats.getAttacked() && !creatureStats.isHostile())
|
else if (creatureStats.getAttacked() && !creatureStats.isHostile())
|
||||||
{
|
{
|
||||||
|
|
|
@ -93,11 +93,16 @@ void MWMechanics::AiSequence::execute (const MWWorld::Ptr& actor,float duration)
|
||||||
{
|
{
|
||||||
if (!mPackages.empty())
|
if (!mPackages.empty())
|
||||||
{
|
{
|
||||||
mLastAiPackage = mPackages.front()->getTypeId();
|
MWMechanics::AiPackage* package = mPackages.front();
|
||||||
if (mPackages.front()->execute (actor,duration))
|
mLastAiPackage = package->getTypeId();
|
||||||
|
if (package->execute (actor,duration))
|
||||||
{
|
{
|
||||||
delete *mPackages.begin();
|
// To account for the rare case where AiPackage::execute() queued another AI package
|
||||||
mPackages.erase (mPackages.begin());
|
// (e.g. AiPersue executing a dialogue script that uses startCombat)
|
||||||
|
std::list<MWMechanics::AiPackage*>::iterator toRemove =
|
||||||
|
std::find(mPackages.begin(), mPackages.end(), package);
|
||||||
|
mPackages.erase(toRemove);
|
||||||
|
delete package;
|
||||||
mDone = true;
|
mDone = true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
|
@ -33,7 +33,7 @@ struct Creature
|
||||||
|
|
||||||
Respawn = 0x002,
|
Respawn = 0x002,
|
||||||
Weapon = 0x004, // Has weapon and shield
|
Weapon = 0x004, // Has weapon and shield
|
||||||
None = 0x008, // ??
|
None = 0x008, // ?? This flag appears set for every creature in Morrowind.esm
|
||||||
Essential = 0x080,
|
Essential = 0x080,
|
||||||
|
|
||||||
// Blood types
|
// Blood types
|
||||||
|
|
Loading…
Reference in a new issue