forked from teamnwah/openmw-tes3coop
Added update sneak to actors
Intends to check the state of a players sneak by asking the question if each npc can see the player.
This commit is contained in:
parent
5c9c467b26
commit
05e326bdc3
3 changed files with 25 additions and 5 deletions
|
@ -236,6 +236,7 @@ namespace MWMechanics
|
|||
updateDrowning(ptr, duration);
|
||||
calculateNpcStatModifiers(ptr);
|
||||
updateEquippedLight(ptr, duration);
|
||||
updateSneak(ptr);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -720,6 +721,28 @@ namespace MWMechanics
|
|||
}
|
||||
}
|
||||
|
||||
void Actors::updateSneak (const MWWorld::Ptr& ptr)
|
||||
{
|
||||
const MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayerPtr();
|
||||
if (player.getClass().getCreatureStats(player).getMovementFlag(MWMechanics::CreatureStats::Flag_Sneak))
|
||||
{
|
||||
const MWWorld::ESMStore& esmStore = MWBase::Environment::get().getWorld()->getStore();
|
||||
int radius = esmStore.get<ESM::GameSetting>().find("fSneakUseDist")->getInt();
|
||||
|
||||
// am I close enough to the player?
|
||||
if (Ogre::Vector3(ptr.getRefData().getPosition().pos).squaredDistance(Ogre::Vector3(player.getRefData().getPosition().pos))
|
||||
<= radius * radius )
|
||||
{
|
||||
bool seen = false; // unseen
|
||||
if ( !MWBase::Environment::get().getMechanicsManager()->awarenessCheck(player, ptr)
|
||||
&& !MWBase::Environment::get().getWorld()->getLOS(player, ptr) )
|
||||
seen = true; // seen
|
||||
|
||||
MWBase::Environment::get().getWindowManager()->setSneakVisibility(seen);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Actors::updateCrimePersuit(const MWWorld::Ptr& ptr, float duration)
|
||||
{
|
||||
MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayerPtr();
|
||||
|
|
|
@ -44,6 +44,8 @@ namespace MWMechanics
|
|||
|
||||
void updateCrimePersuit (const MWWorld::Ptr& ptr, float duration);
|
||||
|
||||
void updateSneak (const MWWorld::Ptr& ptr);
|
||||
|
||||
public:
|
||||
|
||||
Actors();
|
||||
|
|
|
@ -100,7 +100,6 @@ namespace MWWorld
|
|||
void Player::setLeftRight (int value)
|
||||
{
|
||||
MWWorld::Ptr ptr = getPlayer();
|
||||
|
||||
MWWorld::Class::get (ptr).getMovementSettings (ptr).mPosition[0] = value;
|
||||
}
|
||||
|
||||
|
@ -119,7 +118,6 @@ namespace MWWorld
|
|||
void Player::setUpDown(int value)
|
||||
{
|
||||
MWWorld::Ptr ptr = getPlayer();
|
||||
|
||||
MWWorld::Class::get (ptr).getMovementSettings (ptr).mPosition[2] = value;
|
||||
}
|
||||
|
||||
|
@ -132,7 +130,6 @@ namespace MWWorld
|
|||
void Player::setSneak(bool sneak)
|
||||
{
|
||||
MWWorld::Ptr ptr = getPlayer();
|
||||
|
||||
ptr.getClass().getCreatureStats(ptr).setMovementFlag(MWMechanics::CreatureStats::Flag_Sneak, sneak);
|
||||
|
||||
if (sneak)
|
||||
|
@ -157,8 +154,6 @@ namespace MWWorld
|
|||
if (neighbors.empty())
|
||||
MWBase::Environment::get().getWindowManager()->setSneakVisibility(true);
|
||||
}
|
||||
else
|
||||
MWBase::Environment::get().getWindowManager()->setSneakVisibility(false);
|
||||
}
|
||||
|
||||
void Player::yaw(float yaw)
|
||||
|
|
Loading…
Reference in a new issue