1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-02-21 22:09:39 +00:00

Implement disposition changes due to crimes

This commit is contained in:
scrawl 2014-12-18 22:27:09 +01:00
parent cc9af9562b
commit 1910327469

View file

@ -1001,16 +1001,31 @@ namespace MWMechanics
victim.getClass().getCreatureStats(victim).notifyMurder(); victim.getClass().getCreatureStats(victim).notifyMurder();
// Bounty for each type of crime // Bounty for each type of crime
float dispTerm = 0.f, dispTermVictim = 0.f;
if (type == OT_Trespassing || type == OT_SleepingInOwnedBed) if (type == OT_Trespassing || type == OT_SleepingInOwnedBed)
{
arg = store.find("iCrimeTresspass")->getInt(); arg = store.find("iCrimeTresspass")->getInt();
dispTerm = dispTermVictim = store.find("iDispTresspass")->getInt();
}
else if (type == OT_Pickpocket) else if (type == OT_Pickpocket)
{
arg = store.find("iCrimePickPocket")->getInt(); arg = store.find("iCrimePickPocket")->getInt();
dispTerm = dispTermVictim = store.find("fDispPickPocketMod")->getFloat();
}
else if (type == OT_Assault) else if (type == OT_Assault)
{
arg = store.find("iCrimeAttack")->getInt(); arg = store.find("iCrimeAttack")->getInt();
dispTerm = store.find("fDispAttacking")->getFloat();
dispTermVictim = store.find("iDispAttackMod")->getInt();
}
else if (type == OT_Murder) else if (type == OT_Murder)
{
arg = store.find("iCrimeKilling")->getInt(); arg = store.find("iCrimeKilling")->getInt();
dispTerm = dispTermVictim = store.find("iDispKilling")->getInt();
}
else if (type == OT_Theft) else if (type == OT_Theft)
{ {
dispTerm = dispTermVictim = store.find("fDispStealing")->getFloat() * arg;
arg *= store.find("fCrimeStealing")->getFloat(); arg *= store.find("fCrimeStealing")->getFloat();
arg = std::max(1, arg); // Minimum bounty of 1, in case items with zero value are stolen arg = std::max(1, arg); // Minimum bounty of 1, in case items with zero value are stolen
} }
@ -1049,19 +1064,23 @@ namespace MWMechanics
// What amount of provocation did this crime generate? // What amount of provocation did this crime generate?
// Controls whether witnesses will engage combat with the criminal. // Controls whether witnesses will engage combat with the criminal.
int fight = 0; int fight = 0, fightVictim = 0;
if (type == OT_Trespassing || type == OT_SleepingInOwnedBed) if (type == OT_Trespassing || type == OT_SleepingInOwnedBed)
fight = esmStore.get<ESM::GameSetting>().find("iFightTrespass")->getInt(); fight = fightVictim = esmStore.get<ESM::GameSetting>().find("iFightTrespass")->getInt();
else if (type == OT_Pickpocket) else if (type == OT_Pickpocket)
fight = esmStore.get<ESM::GameSetting>().find("iFightPickpocket")->getInt() * 4; // *4 according to research wiki {
else if (type == OT_Assault) // Note: iFightAttack is for the victim, iFightAttacking for witnesses? fight = esmStore.get<ESM::GameSetting>().find("iFightPickpocket")->getInt();
fightVictim = esmStore.get<ESM::GameSetting>().find("iFightPickpocket")->getInt() * 4; // *4 according to research wiki
}
else if (type == OT_Assault)
{
fight = esmStore.get<ESM::GameSetting>().find("iFightAttack")->getInt(); fight = esmStore.get<ESM::GameSetting>().find("iFightAttack")->getInt();
fightVictim = esmStore.get<ESM::GameSetting>().find("iFightAttacking")->getInt();
}
else if (type == OT_Murder) else if (type == OT_Murder)
fight = esmStore.get<ESM::GameSetting>().find("iFightKilling")->getInt(); fight = fightVictim = esmStore.get<ESM::GameSetting>().find("iFightKilling")->getInt();
else if (type == OT_Theft) else if (type == OT_Theft)
fight = esmStore.get<ESM::GameSetting>().find("fFightStealing")->getFloat(); fight = fightVictim = esmStore.get<ESM::GameSetting>().find("fFightStealing")->getFloat();
const int iFightAttacking = esmStore.get<ESM::GameSetting>().find("iFightAttacking")->getInt();
// Tell everyone (including the original reporter) in alarm range // Tell everyone (including the original reporter) in alarm range
for (std::vector<MWWorld::Ptr>::iterator it = neighbors.begin(); it != neighbors.end(); ++it) for (std::vector<MWWorld::Ptr>::iterator it = neighbors.begin(); it != neighbors.end(); ++it)
@ -1069,11 +1088,7 @@ namespace MWMechanics
if ( *it == player if ( *it == player
|| !it->getClass().isNpc() || it->getClass().getCreatureStats(*it).isDead()) continue; || !it->getClass().isNpc() || it->getClass().getCreatureStats(*it).isDead()) continue;
int aggression = fight; int aggression = (*it == victim) ? fightVictim : fight;
// Note: iFightAttack is used for the victim, iFightAttacking for witnesses?
if (*it != victim && type == OT_Assault)
aggression = iFightAttacking;
if (it->getClass().getCreatureStats(*it).getAiSequence().isInCombat(victim)) if (it->getClass().getCreatureStats(*it).getAiSequence().isInCombat(victim))
continue; continue;
@ -1091,6 +1106,11 @@ namespace MWMechanics
} }
else else
{ {
int dispChange = (*it == victim) ? dispTermVictim : dispTerm;
NpcStats& observerStats = it->getClass().getNpcStats(*it);
int originalDisposition = observerStats.getBaseDisposition();
observerStats.setBaseDisposition(originalDisposition+dispChange);
bool aggressive = MWBase::Environment::get().getMechanicsManager()->isAggressive(*it, player, aggression, true); bool aggressive = MWBase::Environment::get().getMechanicsManager()->isAggressive(*it, player, aggression, true);
if (aggressive) if (aggressive)
{ {
@ -1108,6 +1128,8 @@ namespace MWMechanics
// Mark as Alarmed for dialogue // Mark as Alarmed for dialogue
it->getClass().getCreatureStats(*it).setAlarmed(true); it->getClass().getCreatureStats(*it).setAlarmed(true);
} }
else
observerStats.setBaseDisposition(originalDisposition);
} }
} }
} }