mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-03-25 16:43:33 +00:00
Count werewolf kills (Fixes #1525)
This commit is contained in:
parent
1244da85df
commit
1dc9e151cb
@ -757,11 +757,16 @@ namespace MWClass
|
|||||||
if (!wasDead && getCreatureStats(ptr).isDead())
|
if (!wasDead && getCreatureStats(ptr).isDead())
|
||||||
{
|
{
|
||||||
// NPC was killed
|
// NPC was killed
|
||||||
|
if (!attacker.isEmpty() && attacker.getClass().isNpc() && attacker.getClass().getNpcStats(attacker).isWerewolf())
|
||||||
|
{
|
||||||
|
attacker.getClass().getNpcStats(attacker).addWerewolfKill();
|
||||||
|
}
|
||||||
|
|
||||||
// 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.
|
||||||
MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayerPtr();
|
MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayerPtr();
|
||||||
if (ptr.getClass().getNpcStats(ptr).getCrimeId() != -1 && ptr != player)
|
if (attacker == player && ptr.getClass().getNpcStats(ptr).getCrimeId() != -1 && ptr != player)
|
||||||
MWBase::Environment::get().getMechanicsManager()->commitCrime(player, ptr, MWBase::MechanicsManager::OT_Murder);
|
MWBase::Environment::get().getMechanicsManager()->commitCrime(player, ptr, MWBase::MechanicsManager::OT_Murder);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -460,6 +460,9 @@ 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;
|
||||||
|
bool murderedByPlayer = false;
|
||||||
|
MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayerPtr();
|
||||||
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;
|
||||||
@ -478,20 +481,23 @@ namespace MWMechanics
|
|||||||
if (effectId == ESM::MagicEffect::DamageHealth || effectId == ESM::MagicEffect::AbsorbHealth)
|
if (effectId == ESM::MagicEffect::DamageHealth || effectId == ESM::MagicEffect::AbsorbHealth)
|
||||||
isDamageEffect = true;
|
isDamageEffect = true;
|
||||||
|
|
||||||
MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayerPtr();
|
|
||||||
MWWorld::Ptr caster = MWBase::Environment::get().getWorld()->searchPtrViaActorId(spell.mCasterActorId);
|
MWWorld::Ptr caster = MWBase::Environment::get().getWorld()->searchPtrViaActorId(spell.mCasterActorId);
|
||||||
if (isDamageEffect && caster == player)
|
if (isDamageEffect && caster == player)
|
||||||
{
|
{
|
||||||
|
killedByPlayer = true;
|
||||||
// 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 (ptr.getClass().isNpc() && ptr.getClass().getNpcStats(ptr).getCrimeId() != -1
|
if (ptr.getClass().isNpc() && ptr.getClass().getNpcStats(ptr).getCrimeId() != -1
|
||||||
&& ptr != player)
|
&& ptr != player)
|
||||||
MWBase::Environment::get().getMechanicsManager()->commitCrime(player, ptr, MWBase::MechanicsManager::OT_Murder);
|
murderedByPlayer = true;
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (murderedByPlayer)
|
||||||
|
MWBase::Environment::get().getMechanicsManager()->commitCrime(player, ptr, MWBase::MechanicsManager::OT_Murder);
|
||||||
|
if (killedByPlayer && player.getClass().getNpcStats(player).isWerewolf())
|
||||||
|
player.getClass().getNpcStats(player).addWerewolfKill();
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: dirty flag for magic effects to avoid some unnecessary work below?
|
// TODO: dirty flag for magic effects to avoid some unnecessary work below?
|
||||||
|
@ -396,6 +396,8 @@ void MWMechanics::NpcStats::setWerewolf (bool set)
|
|||||||
{
|
{
|
||||||
const MWWorld::Store<ESM::GameSetting> &gmst = MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>();
|
const MWWorld::Store<ESM::GameSetting> &gmst = MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>();
|
||||||
|
|
||||||
|
mWerewolfKills = 0;
|
||||||
|
|
||||||
for(size_t i = 0;i < ESM::Attribute::Length;i++)
|
for(size_t i = 0;i < ESM::Attribute::Length;i++)
|
||||||
{
|
{
|
||||||
mWerewolfAttributes[i] = getAttribute(i);
|
mWerewolfAttributes[i] = getAttribute(i);
|
||||||
@ -427,6 +429,11 @@ int MWMechanics::NpcStats::getWerewolfKills() const
|
|||||||
return mWerewolfKills;
|
return mWerewolfKills;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MWMechanics::NpcStats::addWerewolfKill()
|
||||||
|
{
|
||||||
|
++mWerewolfKills;
|
||||||
|
}
|
||||||
|
|
||||||
int MWMechanics::NpcStats::getProfit() const
|
int MWMechanics::NpcStats::getProfit() const
|
||||||
{
|
{
|
||||||
return mProfit;
|
return mProfit;
|
||||||
|
@ -126,6 +126,9 @@ namespace MWMechanics
|
|||||||
|
|
||||||
int getWerewolfKills() const;
|
int getWerewolfKills() const;
|
||||||
|
|
||||||
|
/// Increments mWerewolfKills by 1.
|
||||||
|
void addWerewolfKill();
|
||||||
|
|
||||||
float getTimeToStartDrowning() const;
|
float getTimeToStartDrowning() const;
|
||||||
/// Sets time left for the creature to drown if it stays underwater.
|
/// Sets time left for the creature to drown if it stays underwater.
|
||||||
/// @param time value from [0,20]
|
/// @param time value from [0,20]
|
||||||
|
@ -441,7 +441,7 @@ namespace Compiler
|
|||||||
|
|
||||||
extensions.registerFunction ("getrace", 'l', "c", opcodeGetRace,
|
extensions.registerFunction ("getrace", 'l', "c", opcodeGetRace,
|
||||||
opcodeGetRaceExplicit);
|
opcodeGetRaceExplicit);
|
||||||
extensions.registerFunction ("getwerewolfkills", 'f', "", opcodeGetWerewolfKills);
|
extensions.registerFunction ("getwerewolfkills", 'l', "", opcodeGetWerewolfKills);
|
||||||
extensions.registerFunction ("pcexpelled", 'l', "/S", opcodePcExpelled, opcodePcExpelledExplicit);
|
extensions.registerFunction ("pcexpelled", 'l', "/S", opcodePcExpelled, opcodePcExpelledExplicit);
|
||||||
extensions.registerInstruction ("pcexpell", "/S", opcodePcExpell, opcodePcExpellExplicit);
|
extensions.registerInstruction ("pcexpell", "/S", opcodePcExpell, opcodePcExpellExplicit);
|
||||||
extensions.registerInstruction ("pcclearexpelled", "/S", opcodePcClearExpelled, opcodePcClearExpelledExplicit);
|
extensions.registerInstruction ("pcclearexpelled", "/S", opcodePcClearExpelled, opcodePcClearExpelledExplicit);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user