mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-02-01 18:15:32 +00:00
Merge remote-tracking branch 'mrcheko/master'
This commit is contained in:
commit
01c90a3434
2 changed files with 33 additions and 4 deletions
|
@ -390,8 +390,11 @@ namespace MWMechanics
|
||||||
bool canMoveByZ = (actorClass.canSwim(actor) && world->isSwimming(actor))
|
bool canMoveByZ = (actorClass.canSwim(actor) && world->isSwimming(actor))
|
||||||
|| world->isFlying(actor);
|
|| world->isFlying(actor);
|
||||||
|
|
||||||
|
// for distant combat we should know if target is in LOS even if distToTarget < rangeAttack
|
||||||
|
bool inLOS = distantCombat ? world->getLOS(actor, target) : true;
|
||||||
|
|
||||||
// (within attack dist) || (not quite attack dist while following)
|
// (within attack dist) || (not quite attack dist while following)
|
||||||
if(distToTarget < rangeAttack || (distToTarget <= rangeFollow && mFollowTarget && !isStuck) )
|
if(inLOS && (distToTarget < rangeAttack || (distToTarget <= rangeFollow && mFollowTarget && !isStuck)))
|
||||||
{
|
{
|
||||||
//Melee and Close-up combat
|
//Melee and Close-up combat
|
||||||
|
|
||||||
|
@ -450,7 +453,7 @@ namespace MWMechanics
|
||||||
else // remote pathfinding
|
else // remote pathfinding
|
||||||
{
|
{
|
||||||
bool preferShortcut = false;
|
bool preferShortcut = false;
|
||||||
bool inLOS = world->getLOS(actor, target);
|
if (!distantCombat) inLOS = world->getLOS(actor, target);
|
||||||
|
|
||||||
// check if shortcut is available
|
// check if shortcut is available
|
||||||
if(inLOS && (!isStuck || mReadyToAttack)
|
if(inLOS && (!isStuck || mReadyToAttack)
|
||||||
|
|
|
@ -853,8 +853,15 @@ namespace MWMechanics
|
||||||
|
|
||||||
// Find all the actors within the alarm radius
|
// Find all the actors within the alarm radius
|
||||||
std::vector<MWWorld::Ptr> neighbors;
|
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();
|
int id = MWBase::Environment::get().getWorld()->getPlayer().getNewCrimeId();
|
||||||
|
|
||||||
|
@ -1024,8 +1031,27 @@ namespace MWMechanics
|
||||||
{
|
{
|
||||||
ptr.getClass().getCreatureStats(ptr).getAiSequence().stack(MWMechanics::AiCombat(target), ptr);
|
ptr.getClass().getCreatureStats(ptr).getAiSequence().stack(MWMechanics::AiCombat(target), ptr);
|
||||||
if (target == MWBase::Environment::get().getWorld()->getPlayerPtr())
|
if (target == MWBase::Environment::get().getWorld()->getPlayerPtr())
|
||||||
|
{
|
||||||
ptr.getClass().getCreatureStats(ptr).setHostile(true);
|
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
|
// Must be done after the target is set up, so that CreatureTargetted dialogue filter works properly
|
||||||
if (ptr.getClass().isNpc())
|
if (ptr.getClass().isNpc())
|
||||||
MWBase::Environment::get().getDialogueManager()->say(ptr, "attack");
|
MWBase::Environment::get().getDialogueManager()->say(ptr, "attack");
|
||||||
|
|
Loading…
Reference in a new issue