Add murder bounty when a player follower commits murder (bug #2852)

pull/456/head
Andrei Kortunov 7 years ago
parent ccfc07e7e3
commit 9c3da41130

@ -5,6 +5,7 @@
Bug #2222: Fatigue's effect on selling price is backwards Bug #2222: Fatigue's effect on selling price is backwards
Bug #2326: After a bound item expires the last equipped item of that type is not automatically re-equipped Bug #2326: After a bound item expires the last equipped item of that type is not automatically re-equipped
Bug #2835: Player able to slowly move when overencumbered Bug #2835: Player able to slowly move when overencumbered
Bug #2852: No murder bounty when a player follower commits murder
Bug #2971: Compiler did not reject lines with naked expressions beginning with x.y Bug #2971: Compiler did not reject lines with naked expressions beginning with x.y
Bug #3374: Touch spells not hitting kwama foragers Bug #3374: Touch spells not hitting kwama foragers
Bug #3591: Angled hit distance too low Bug #3591: Angled hit distance too low

@ -760,11 +760,14 @@ namespace MWMechanics
{ {
// The actor was killed by a magic effect. Figure out if the player was responsible for it. // The actor was killed by a magic effect. Figure out if the player was responsible for it.
const ActiveSpells& spells = creatureStats.getActiveSpells(); const ActiveSpells& spells = creatureStats.getActiveSpells();
bool killedByPlayer = false;
MWWorld::Ptr player = getPlayer(); MWWorld::Ptr player = getPlayer();
std::set<MWWorld::Ptr> playerFollowers;
getActorsSidingWith(player, playerFollowers);
for (ActiveSpells::TIterator it = spells.begin(); it != spells.end(); ++it) for (ActiveSpells::TIterator it = spells.begin(); it != spells.end(); ++it)
{ {
const ActiveSpells::ActiveSpellParams& spell = it->second; const ActiveSpells::ActiveSpellParams& spell = it->second;
MWWorld::Ptr caster = MWBase::Environment::get().getWorld()->searchPtrViaActorId(spell.mCasterActorId);
for (std::vector<ActiveSpells::ActiveEffect>::const_iterator effectIt = spell.mEffects.begin(); for (std::vector<ActiveSpells::ActiveEffect>::const_iterator effectIt = spell.mEffects.begin();
effectIt != spell.mEffects.end(); ++effectIt) effectIt != spell.mEffects.end(); ++effectIt)
{ {
@ -782,16 +785,18 @@ namespace MWMechanics
isDamageEffect = true; isDamageEffect = true;
} }
MWWorld::Ptr caster = MWBase::Environment::get().getWorld()->searchPtrViaActorId(spell.mCasterActorId); if (isDamageEffect)
if (isDamageEffect && caster == player) {
killedByPlayer = true; if (caster == player || playerFollowers.find(caster) != playerFollowers.end())
}
}
if (killedByPlayer)
{ {
if (caster.getClass().getNpcStats(caster).isWerewolf())
caster.getClass().getNpcStats(caster).addWerewolfKill();
MWBase::Environment::get().getMechanicsManager()->actorKilled(ptr, player); MWBase::Environment::get().getMechanicsManager()->actorKilled(ptr, player);
if (player.getClass().getNpcStats(player).isWerewolf()) break;
player.getClass().getNpcStats(player).addWerewolfKill(); }
}
}
} }
} }

@ -1495,7 +1495,7 @@ namespace MWMechanics
void MechanicsManager::actorKilled(const MWWorld::Ptr &victim, const MWWorld::Ptr &attacker) void MechanicsManager::actorKilled(const MWWorld::Ptr &victim, const MWWorld::Ptr &attacker)
{ {
if (attacker.isEmpty() || attacker != getPlayer()) if (attacker.isEmpty() || victim.isEmpty())
return; return;
if (victim == attacker) if (victim == attacker)
@ -1505,13 +1505,23 @@ namespace MWMechanics
return; // TODO: implement animal rights return; // TODO: implement animal rights
const MWMechanics::NpcStats& victimStats = victim.getClass().getNpcStats(victim); const MWMechanics::NpcStats& victimStats = victim.getClass().getNpcStats(victim);
if (victimStats.getCrimeId() == -1)
return;
// For now we report only about crimes of player and player's followers
const MWWorld::Ptr &player = getPlayer();
if (attacker != player)
{
std::set<MWWorld::Ptr> playerFollowers;
getActorsSidingWith(player, playerFollowers);
if (playerFollowers.find(attacker) == playerFollowers.end())
return;
}
// Simple check for who attacked first: if the player attacked first, a crimeId should be set // Simple check for who attacked first: if the player attacked first, a crimeId should be set
// Doesn't handle possible edge case where no one reported the assault, but in such a case, // Doesn't handle possible edge case where no one reported the assault, but in such a case,
// for bystanders it is not possible to tell who attacked first, anyway. // for bystanders it is not possible to tell who attacked first, anyway.
if (victimStats.getCrimeId() != -1) commitCrime(player, victim, MWBase::MechanicsManager::OT_Murder);
commitCrime(attacker, victim, MWBase::MechanicsManager::OT_Murder);
} }
bool MechanicsManager::awarenessCheck(const MWWorld::Ptr &ptr, const MWWorld::Ptr &observer) bool MechanicsManager::awarenessCheck(const MWWorld::Ptr &ptr, const MWWorld::Ptr &observer)

Loading…
Cancel
Save