From 84909c2a5f074f17e716116c56df0cad74393c55 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Tue, 15 Jan 2013 04:05:25 +0300 Subject: Allow talk to not selected closest npc (distance 1) by talk key. Default key T. --- src/actionmanager.cpp | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'src/actionmanager.cpp') 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()) -- cgit v1.2.3-70-g09d2