Merge branch 'StackValueAffectsFightTerm' into 'master'

Make item value affect theft observer's fight willingness

Closes #8500

See merge request OpenMW/openmw!4673
This commit is contained in:
psi29a 2025-07-01 21:37:28 +00:00
commit aa652a20f0

View File

@ -1232,33 +1232,39 @@ namespace MWMechanics
victim.getClass().getCreatureStats(victim).notifyMurder();
// Bounty and disposition penalty for each type of crime
float disp = 0.f, dispVictim = 0.f;
int bounty;
float disp, dispVictim;
if (type == OT_Trespassing || type == OT_SleepingInOwnedBed)
{
arg = store.find("iCrimeTresspass")->mValue.getInteger();
bounty = store.find("iCrimeTresspass")->mValue.getInteger();
disp = dispVictim = store.find("iDispTresspass")->mValue.getFloat();
}
else if (type == OT_Pickpocket)
{
arg = store.find("iCrimePickPocket")->mValue.getInteger();
bounty = store.find("iCrimePickPocket")->mValue.getInteger();
disp = dispVictim = store.find("fDispPickPocketMod")->mValue.getFloat();
}
else if (type == OT_Assault)
{
arg = store.find("iCrimeAttack")->mValue.getInteger();
bounty = store.find("iCrimeAttack")->mValue.getInteger();
disp = store.find("iDispAttackMod")->mValue.getFloat();
dispVictim = store.find("fDispAttacking")->mValue.getFloat();
}
else if (type == OT_Murder)
{
arg = store.find("iCrimeKilling")->mValue.getInteger();
bounty = store.find("iCrimeKilling")->mValue.getInteger();
disp = dispVictim = store.find("iDispKilling")->mValue.getFloat();
}
else if (type == OT_Theft)
{
bounty = static_cast<int>(arg * store.find("fCrimeStealing")->mValue.getFloat());
bounty = std::max(1, bounty); // Minimum bounty of 1, in case items with zero value are stolen
disp = dispVictim = store.find("fDispStealing")->mValue.getFloat() * arg;
arg = static_cast<int>(arg * store.find("fCrimeStealing")->mValue.getFloat());
arg = std::max(1, arg); // Minimum bounty of 1, in case items with zero value are stolen
}
else
{
bounty = arg;
disp = dispVictim = 0.f;
}
// Make surrounding actors within alarm distance respond to the crime
@ -1296,7 +1302,7 @@ namespace MWMechanics
else if (type == OT_Murder)
fight = fightVictim = esmStore.get<ESM::GameSetting>().find("iFightKilling")->mValue.getInteger();
else if (type == OT_Theft)
fight = fightVictim = esmStore.get<ESM::GameSetting>().find("fFightStealing")->mValue.getInteger();
fight = fightVictim = esmStore.get<ESM::GameSetting>().find("fFightStealing")->mValue.getInteger() * arg;
bool reported = false;
@ -1457,7 +1463,7 @@ namespace MWMechanics
if (reported)
{
player.getClass().getNpcStats(player).setBounty(
std::max(0, player.getClass().getNpcStats(player).getBounty() + arg));
std::max(0, player.getClass().getNpcStats(player).getBounty() + bounty));
// If committing a crime against a faction member, expell from the faction
if (!victim.isEmpty() && victim.getClass().isNpc())