forked from mirror/openmw-tes3mp
getLineOfSight, no script instruction yet
This commit is contained in:
parent
2515a1239e
commit
d7584f9df7
2 changed files with 14 additions and 2 deletions
|
@ -82,7 +82,8 @@ void MWMechanics::AiSequence::execute (const MWWorld::Ptr& actor)
|
|||
+(actorpos.pos[2] - playerpos.pos[2])*(actorpos.pos[2] - playerpos.pos[2]));
|
||||
float fight = actor.getClass().getCreatureStats(actor).getAiSetting(1);
|
||||
float disp = MWBase::Environment::get().getMechanicsManager()->getDerivedDisposition(actor);
|
||||
if(fight == 100
|
||||
bool LOS = MWBase::Environment::get().getWorld()->getLOS(actor,MWBase::Environment::get().getWorld()->getPlayer().getPlayer());
|
||||
if( ( (fight == 100 )
|
||||
|| (fight >= 95 && d <= 3000)
|
||||
|| (fight >= 90 && d <= 2000)
|
||||
|| (fight >= 80 && d <= 1000)
|
||||
|
@ -90,7 +91,8 @@ void MWMechanics::AiSequence::execute (const MWWorld::Ptr& actor)
|
|||
|| (fight >= 70 && disp <= 35 && d <= 1000)
|
||||
|| (fight >= 60 && disp <= 30 && d <= 1000)
|
||||
|| (fight >= 50 && disp == 0)
|
||||
|| (fight >= 40 && disp <= 10 && d <= 500)
|
||||
|| (fight >= 40 && disp <= 10 && d <= 500) )
|
||||
&& LOS
|
||||
)
|
||||
{
|
||||
mCombat = true;
|
||||
|
|
|
@ -1786,6 +1786,16 @@ namespace MWWorld
|
|||
|
||||
bool World::getLOS(const MWWorld::Ptr& npc,const MWWorld::Ptr& targetNpc)
|
||||
{
|
||||
Ogre::Vector3 halfExt1 = mPhysEngine->getCharacter(npc.getRefData().getHandle())->getHalfExtents();
|
||||
float* pos1 = npc.getRefData().getPosition().pos;
|
||||
Ogre::Vector3 halfExt2 = mPhysEngine->getCharacter(targetNpc.getRefData().getHandle())->getHalfExtents();
|
||||
float* pos2 = targetNpc.getRefData().getPosition().pos;
|
||||
|
||||
btVector3 from(pos1[0],pos1[1],pos1[2]+halfExt1.z);
|
||||
btVector3 to(pos2[0],pos2[1],pos2[2]+halfExt2.z);
|
||||
|
||||
std::pair<std::string, float> result = mPhysEngine->rayTest(from, to,false);
|
||||
if(result.first == "") return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue