forked from mirror/openmw-tes3mp
Implement Assault crimes. In other words, NPCs now fight back!
This commit is contained in:
parent
12944f2459
commit
909494ff35
3 changed files with 17 additions and 5 deletions
|
@ -587,6 +587,10 @@ namespace MWClass
|
||||||
|
|
||||||
// NOTE: 'object' and/or 'attacker' may be empty.
|
// NOTE: 'object' and/or 'attacker' may be empty.
|
||||||
|
|
||||||
|
// Attacking peaceful NPCs is a crime
|
||||||
|
if (ptr.getClass().getCreatureStats(ptr).getAiSetting(MWMechanics::CreatureStats::AI_Fight).getModified() <= 30)
|
||||||
|
MWBase::Environment::get().getMechanicsManager()->commitCrime(attacker, ptr, MWBase::MechanicsManager::OT_Assault);
|
||||||
|
|
||||||
if(!successful)
|
if(!successful)
|
||||||
{
|
{
|
||||||
// TODO: Handle HitAttemptOnMe script function
|
// TODO: Handle HitAttemptOnMe script function
|
||||||
|
|
|
@ -786,7 +786,8 @@ namespace MWMechanics
|
||||||
|
|
||||||
bool MechanicsManager::commitCrime(const MWWorld::Ptr &ptr, const MWWorld::Ptr &victim, OffenseType type, int arg)
|
bool MechanicsManager::commitCrime(const MWWorld::Ptr &ptr, const MWWorld::Ptr &victim, OffenseType type, int arg)
|
||||||
{
|
{
|
||||||
// TODO: expell from faction
|
if (ptr.getRefData().getHandle() != "player")
|
||||||
|
return false;
|
||||||
|
|
||||||
bool reported=false;
|
bool reported=false;
|
||||||
for (Actors::PtrControllerMap::const_iterator it = mActors.begin(); it != mActors.end(); ++it)
|
for (Actors::PtrControllerMap::const_iterator it = mActors.begin(); it != mActors.end(); ++it)
|
||||||
|
@ -803,10 +804,7 @@ namespace MWMechanics
|
||||||
|
|
||||||
// Actor has witnessed a crime. Will he report it?
|
// Actor has witnessed a crime. Will he report it?
|
||||||
// (not sure, is > 0 correct?)
|
// (not sure, is > 0 correct?)
|
||||||
if (it->first.getClass().getCreatureStats(it->first).getAiSetting(CreatureStats::AI_Alarm).getModified() > 0
|
if (it->first.getClass().getCreatureStats(it->first).getAiSetting(CreatureStats::AI_Alarm).getModified() > 0)
|
||||||
// This is a bit inconsistent, but AFAIK assaulted NPCs can not report if they are alone
|
|
||||||
&& (type != OT_Assault || it->first != victim)
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
// TODO: stats.setAlarmed(true) on NPCs within earshot
|
// TODO: stats.setAlarmed(true) on NPCs within earshot
|
||||||
// fAlarmRadius ?
|
// fAlarmRadius ?
|
||||||
|
@ -836,6 +834,9 @@ namespace MWMechanics
|
||||||
else if (type == OT_Theft)
|
else if (type == OT_Theft)
|
||||||
arg *= store.find("fCrimeStealing")->getFloat();
|
arg *= store.find("fCrimeStealing")->getFloat();
|
||||||
|
|
||||||
|
// TODO: In some cases (type == Assault), if no NPCs are within earshot, the report will have no effect.
|
||||||
|
// however other crime types seem to be always produce a bounty.
|
||||||
|
|
||||||
MWBase::Environment::get().getWindowManager()->messageBox("#{sCrimeMessage}");
|
MWBase::Environment::get().getWindowManager()->messageBox("#{sCrimeMessage}");
|
||||||
ptr.getClass().getNpcStats(ptr).setBounty(ptr.getClass().getNpcStats(ptr).getBounty()
|
ptr.getClass().getNpcStats(ptr).setBounty(ptr.getClass().getNpcStats(ptr).getBounty()
|
||||||
+ arg);
|
+ arg);
|
||||||
|
|
|
@ -57,6 +57,7 @@ namespace MWMechanics
|
||||||
ESM::EffectList reflectedEffects;
|
ESM::EffectList reflectedEffects;
|
||||||
std::vector<ActiveSpells::Effect> appliedLastingEffects;
|
std::vector<ActiveSpells::Effect> appliedLastingEffects;
|
||||||
bool firstAppliedEffect = true;
|
bool firstAppliedEffect = true;
|
||||||
|
bool anyHarmfulEffect = false;
|
||||||
|
|
||||||
for (std::vector<ESM::ENAMstruct>::const_iterator effectIt (effects.mList.begin());
|
for (std::vector<ESM::ENAMstruct>::const_iterator effectIt (effects.mList.begin());
|
||||||
effectIt!=effects.mList.end(); ++effectIt)
|
effectIt!=effects.mList.end(); ++effectIt)
|
||||||
|
@ -77,6 +78,8 @@ namespace MWMechanics
|
||||||
float magnitudeMult = 1;
|
float magnitudeMult = 1;
|
||||||
if (magicEffect->mData.mFlags & ESM::MagicEffect::Harmful && target.getClass().isActor())
|
if (magicEffect->mData.mFlags & ESM::MagicEffect::Harmful && target.getClass().isActor())
|
||||||
{
|
{
|
||||||
|
anyHarmfulEffect = true;
|
||||||
|
|
||||||
// If player is attempting to cast a harmful spell, show the target's HP bar
|
// If player is attempting to cast a harmful spell, show the target's HP bar
|
||||||
if (caster.getRefData().getHandle() == "player" && target != caster)
|
if (caster.getRefData().getHandle() == "player" && target != caster)
|
||||||
MWBase::Environment::get().getWindowManager()->setEnemy(target);
|
MWBase::Environment::get().getWindowManager()->setEnemy(target);
|
||||||
|
@ -218,6 +221,10 @@ namespace MWMechanics
|
||||||
if (appliedLastingEffects.size())
|
if (appliedLastingEffects.size())
|
||||||
target.getClass().getCreatureStats(target).getActiveSpells().addSpell(mId, mStack, appliedLastingEffects,
|
target.getClass().getCreatureStats(target).getActiveSpells().addSpell(mId, mStack, appliedLastingEffects,
|
||||||
mSourceName, caster.getRefData().getHandle());
|
mSourceName, caster.getRefData().getHandle());
|
||||||
|
|
||||||
|
if (anyHarmfulEffect && target.getClass().isActor()
|
||||||
|
&& target.getClass().getCreatureStats(target).getAiSetting(MWMechanics::CreatureStats::AI_Fight).getModified() <= 30)
|
||||||
|
MWBase::Environment::get().getMechanicsManager()->commitCrime(caster, target, MWBase::MechanicsManager::OT_Assault);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CastSpell::applyInstantEffect(const MWWorld::Ptr &target, const MWWorld::Ptr &caster, MWMechanics::EffectKey effect, float magnitude)
|
void CastSpell::applyInstantEffect(const MWWorld::Ptr &target, const MWWorld::Ptr &caster, MWMechanics::EffectKey effect, float magnitude)
|
||||||
|
|
Loading…
Reference in a new issue