diff options
author | Ira Rice <irarice@gmail.com> | 2008-10-27 04:23:43 +0000 |
---|---|---|
committer | Ira Rice <irarice@gmail.com> | 2008-10-27 04:23:43 +0000 |
commit | 218ad29dc13b1b89da9804dec15f32692d8709d6 (patch) | |
tree | e1547d951089109de83833fb2a29067fc11eee8c /src/game.cpp | |
parent | 8119f4ec53b64adc427f683077f65ce8aec85582 (diff) | |
download | mana-218ad29dc13b1b89da9804dec15f32692d8709d6.tar.gz mana-218ad29dc13b1b89da9804dec15f32692d8709d6.tar.bz2 mana-218ad29dc13b1b89da9804dec15f32692d8709d6.tar.xz mana-218ad29dc13b1b89da9804dec15f32692d8709d6.zip |
Made targets draw on the fringe layer, as well as added t for talking to
an NPC, n for targeting an NPC, and changed basic targeting code so that
it'll time out after being on a target for longer than a minute.
Diffstat (limited to 'src/game.cpp')
-rw-r--r-- | src/game.cpp | 29 |
1 files changed, 24 insertions, 5 deletions
diff --git a/src/game.cpp b/src/game.cpp index 5e7ee1e8..2fc23a53 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -830,10 +830,7 @@ void Game::handleInput() { Being *target = beingManager->findNearestLivingBeing(player_node, 20, Being::PLAYER); - if (target) - { - player_node->setTarget(target); - } + player_node->setTarget(target); } // Target the nearest monster if 'a' pressed @@ -841,9 +838,31 @@ void Game::handleInput() { Being *target = beingManager->findNearestLivingBeing(x, y, 20, Being::MONSTER); + player_node->setTarget(target); + } + + // Target the nearest npc if 'n' pressed + if ( keyboard.isKeyActive(keyboard.KEY_TARGET_NPC) ) + { + Being *target = beingManager->findNearestLivingBeing(x, y, 20, Being::NPC); + + player_node->setTarget(target); + } + + // Talk to the nearest NPC if 't' pressed + if ( keyboard.isKeyActive(keyboard.KEY_TALK) ) + { + Being *target = player_node->getTarget(); + + if (!target) + { + target = beingManager->findNearestLivingBeing(x, y, 20, Being::NPC); + } + if (target) { - player_node->setTarget(target); + if (target->getType() == Being::NPC) + dynamic_cast<NPC*>(target)->talk(); } } |