diff options
Diffstat (limited to 'src/monster.cpp')
-rw-r--r-- | src/monster.cpp | 47 |
1 files changed, 45 insertions, 2 deletions
diff --git a/src/monster.cpp b/src/monster.cpp index e2a07e86..1a7f6c4e 100644 --- a/src/monster.cpp +++ b/src/monster.cpp @@ -18,7 +18,7 @@ * along with The Mana World; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * - * $Id$ + * $Id: monster.cpp 3823 2007-12-28 18:36:58Z crush_tmw $ */ #include "monster.h" @@ -27,14 +27,21 @@ #include "game.h" #include "sound.h" #include "particle.h" +#include "text.h" +#include "localplayer.h" + +#include "gui/gui.h" #include "resources/monsterdb.h" #include "utils/tostring.h" +static const int NAME_X_OFFSET = 16; +static const int NAME_Y_OFFSET = 16; Monster::Monster(Uint32 id, Uint16 job, Map *map): - Being(id, job, map) + Being(id, job, map), + mText(0) { const MonsterInfo& info = MonsterDB::get(job - 1002); @@ -59,6 +66,14 @@ Monster::Monster(Uint32 id, Uint16 job, Map *map): } } +Monster::~Monster() +{ + if (mText) + { + player_node->setTarget(0); + } +} + void Monster::logic() { @@ -141,3 +156,31 @@ Monster::getInfo() const { return MonsterDB::get(mJob - 1002); } + +void Monster::showName(bool show) +{ + if (mText) + { + delete mText; + } + if (show) + { + mText = new Text(getInfo().getName(), mPx + NAME_X_OFFSET, + mPy + NAME_Y_OFFSET - getHeight(), + gcn::Graphics::CENTER, + speechFont, gcn::Color(255, 32, 32)); + } + else + { + mText = 0; + } +} + +void Monster::updateCoords() +{ + if (mText) + { + mText->adviseXY(mPx + NAME_X_OFFSET, + mPy + NAME_Y_OFFSET - getHeight()); + } +} |