Skip to content

Commit

Permalink
Merge branch 'csicorruption' into 'master'
Browse files Browse the repository at this point in the history
Allow ModPCCrimeLevel to clear crimes and cap bounties

Closes #7416

See merge request OpenMW/openmw!3664
Capostrophic committed Dec 20, 2023
2 parents 7074ea0 + 77cf928 commit d97563c
Showing 4 changed files with 11 additions and 6 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -77,6 +77,7 @@
Bug #7380: NiZBufferProperty issue
Bug #7413: Generated wilderness cells don't spawn fish
Bug #7415: Unbreakable lock discrepancies
Bug #7416: Modpccrimelevel is different from vanilla
Bug #7428: AutoCalc flag is not used to calculate enchantment costs
Bug #7450: Evading obstacles does not work for actors missing certain animations
Bug #7459: Icons get stacked on the cursor when picking up multiple items simultaneously
2 changes: 1 addition & 1 deletion apps/openmw/mwmechanics/actors.cpp
Original file line number Diff line number Diff line change
@@ -1152,7 +1152,7 @@ namespace MWMechanics
if (npcStats.getCrimeId() != -1)
{
// if you've paid for your crimes and I haven't noticed
if (npcStats.getCrimeId() <= world->getPlayer().getCrimeId())
if (npcStats.getCrimeId() <= world->getPlayer().getCrimeId() || playerStats.getBounty() <= 0)
{
// Calm witness down
if (ptr.getClass().isClass(ptr, "Guard"))
6 changes: 4 additions & 2 deletions apps/openmw/mwmechanics/mechanicsmanagerimp.cpp
Original file line number Diff line number Diff line change
@@ -1358,7 +1358,8 @@ namespace MWMechanics

if (reported)
{
player.getClass().getNpcStats(player).setBounty(player.getClass().getNpcStats(player).getBounty() + arg);
player.getClass().getNpcStats(player).setBounty(
std::max(0, player.getClass().getNpcStats(player).getBounty() + arg));

// If committing a crime against a faction member, expell from the faction
if (!victim.isEmpty() && victim.getClass().isNpc())
@@ -1923,7 +1924,8 @@ namespace MWMechanics

if (reported)
{
npcStats.setBounty(npcStats.getBounty() + gmst.find("iWereWolfBounty")->mValue.getInteger());
npcStats.setBounty(
std::max(0, npcStats.getBounty() + gmst.find("iWereWolfBounty")->mValue.getInteger()));
}
}
}
8 changes: 5 additions & 3 deletions apps/openmw/mwscript/statsextensions.cpp
Original file line number Diff line number Diff line change
@@ -445,10 +445,12 @@ namespace MWScript
{
MWBase::World* world = MWBase::Environment::get().getWorld();
MWWorld::Ptr player = world->getPlayerPtr();

player.getClass().getNpcStats(player).setBounty(
static_cast<int>(runtime[0].mFloat) + player.getClass().getNpcStats(player).getBounty());
int bounty = std::max(
0, static_cast<int>(runtime[0].mFloat) + player.getClass().getNpcStats(player).getBounty());
player.getClass().getNpcStats(player).setBounty(bounty);
runtime.pop();
if (bounty == 0)
MWBase::Environment::get().getWorld()->getPlayer().recordCrimeId();
}
};

0 comments on commit d97563c

Please sign in to comment.