summaryrefslogtreecommitdiff
path: root/src/actionmanager.cpp
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2013-01-15 04:05:25 +0300
committerAndrei Karas <akaras@inbox.ru>2013-01-15 04:05:25 +0300
commit84909c2a5f074f17e716116c56df0cad74393c55 (patch)
tree79e1b1a61d51d76399916440398ea3b4d2c72404 /src/actionmanager.cpp
parentc6c549589f4bdd2708bf687acff21bb25e5fde0a (diff)
downloadmv-84909c2a5f074f17e716116c56df0cad74393c55.tar.gz
mv-84909c2a5f074f17e716116c56df0cad74393c55.tar.bz2
mv-84909c2a5f074f17e716116c56df0cad74393c55.tar.xz
mv-84909c2a5f074f17e716116c56df0cad74393c55.zip
Allow talk to not selected closest npc (distance 1) by talk key.
Default key T.
Diffstat (limited to 'src/actionmanager.cpp')
-rw-r--r--src/actionmanager.cpp16
1 files changed, 15 insertions, 1 deletions
diff --git a/src/actionmanager.cpp b/src/actionmanager.cpp
index 337fc4102..ed9e4ae38 100644
--- a/src/actionmanager.cpp
+++ b/src/actionmanager.cpp
@@ -937,7 +937,21 @@ impHandler0(talk)
{
if (player_node)
{
- Being *const target = player_node->getTarget();
+ Being *target = player_node->getTarget();
+ if (!target)
+ {
+ target = actorSpriteManager->findNearestLivingBeing(
+ player_node, 1, ActorSprite::NPC);
+ // ignore closest target if distance in each direction more than 1
+ if (target)
+ {
+ if (abs(target->getTileX() - player_node->getTileX()) > 1
+ || abs(target->getTileY() - player_node->getTileY()) > 1)
+ {
+ return true;
+ }
+ }
+ }
if (target)
{
if (target->canTalk())