|
|
|
@ -853,8 +853,15 @@ namespace MWMechanics
|
|
|
|
|
|
|
|
|
|
// Find all the actors within the alarm radius
|
|
|
|
|
std::vector<MWWorld::Ptr> neighbors;
|
|
|
|
|
mActors.getObjectsInRange(Ogre::Vector3(player.getRefData().getPosition().pos),
|
|
|
|
|
esmStore.get<ESM::GameSetting>().find("fAlarmRadius")->getInt(), neighbors);
|
|
|
|
|
|
|
|
|
|
Ogre::Vector3 from = Ogre::Vector3(player.getRefData().getPosition().pos);
|
|
|
|
|
int radius = esmStore.get<ESM::GameSetting>().find("fAlarmRadius")->getInt();
|
|
|
|
|
|
|
|
|
|
mActors.getObjectsInRange(from, radius, neighbors);
|
|
|
|
|
|
|
|
|
|
// victim should be considered even beyond alarm radius
|
|
|
|
|
if (from.squaredDistance(Ogre::Vector3(victim.getRefData().getPosition().pos)) > radius*radius)
|
|
|
|
|
neighbors.push_back(victim);
|
|
|
|
|
|
|
|
|
|
int id = MWBase::Environment::get().getWorld()->getPlayer().getNewCrimeId();
|
|
|
|
|
|
|
|
|
@ -1024,8 +1031,27 @@ namespace MWMechanics
|
|
|
|
|
{
|
|
|
|
|
ptr.getClass().getCreatureStats(ptr).getAiSequence().stack(MWMechanics::AiCombat(target), ptr);
|
|
|
|
|
if (target == MWBase::Environment::get().getWorld()->getPlayerPtr())
|
|
|
|
|
{
|
|
|
|
|
ptr.getClass().getCreatureStats(ptr).setHostile(true);
|
|
|
|
|
|
|
|
|
|
// if guard starts combat with player, guards pursuing player should do the same
|
|
|
|
|
if (ptr.getClass().isClass(ptr, "Guard"))
|
|
|
|
|
{
|
|
|
|
|
for (Actors::PtrControllerMap::const_iterator iter = mActors.begin(); iter != mActors.end(); ++iter)
|
|
|
|
|
{
|
|
|
|
|
if (iter->first.getClass().isClass(iter->first, "Guard"))
|
|
|
|
|
{
|
|
|
|
|
MWMechanics::AiSequence& aiSeq = iter->first.getClass().getCreatureStats(iter->first).getAiSequence();
|
|
|
|
|
if (aiSeq.getActivePackage()->getTypeId() == MWMechanics::AiPackage::TypeIdPursue)
|
|
|
|
|
{
|
|
|
|
|
aiSeq.stopPursuit();
|
|
|
|
|
aiSeq.stack(MWMechanics::AiCombat(target), ptr);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Must be done after the target is set up, so that CreatureTargetted dialogue filter works properly
|
|
|
|
|
if (ptr.getClass().isNpc())
|
|
|
|
|
MWBase::Environment::get().getDialogueManager()->say(ptr, "attack");
|
|
|
|
|