diff options
author | David Athay <ko2fan@gmail.com> | 2009-02-11 09:30:26 +0000 |
---|---|---|
committer | David Athay <ko2fan@gmail.com> | 2009-02-11 09:30:26 +0000 |
commit | 91111ca5d13072ea3b834e23835df9c077329e39 (patch) | |
tree | f0af8dd08b766164835cf9b5412a9aa3267dbad7 /src/monster.cpp | |
parent | 8046bb2626b30fecdcea54eb0aa3349cdb7d277b (diff) | |
parent | 63ac001daa7dfc0735dfefd9c2829c8786b4edaf (diff) | |
download | mana-91111ca5d13072ea3b834e23835df9c077329e39.tar.gz mana-91111ca5d13072ea3b834e23835df9c077329e39.tar.bz2 mana-91111ca5d13072ea3b834e23835df9c077329e39.tar.xz mana-91111ca5d13072ea3b834e23835df9c077329e39.zip |
Merge branch 'master' of git@gitorious.org:tmw/eathena
Diffstat (limited to 'src/monster.cpp')
-rw-r--r-- | src/monster.cpp | 71 |
1 files changed, 50 insertions, 21 deletions
diff --git a/src/monster.cpp b/src/monster.cpp index f50855ca..8f56560b 100644 --- a/src/monster.cpp +++ b/src/monster.cpp @@ -19,18 +19,16 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include "monster.h" - #include "animatedsprite.h" #include "game.h" -#include "sound.h" +#include "localplayer.h" +#include "monster.h" #include "particle.h" +#include "sound.h" #include "text.h" -#include "localplayer.h" #include "resources/monsterdb.h" - -#include "utils/tostring.h" +#include "resources/monsterinfo.h" static const int NAME_X_OFFSET = 16; static const int NAME_Y_OFFSET = 16; @@ -44,6 +42,7 @@ Monster::Monster(Uint32 id, Uint16 job, Map *map): // Setup Monster sprites int c = BASE_SPRITE; const std::list<std::string> &sprites = info.getSprites(); + for (std::list<std::string>::const_iterator i = sprites.begin(); i != sprites.end(); i++) @@ -61,21 +60,26 @@ Monster::Monster(Uint32 id, Uint16 job, Map *map): mSprites[c] = AnimatedSprite::load("graphics/sprites/error.xml"); } - const std::list<std::string> &particleEffects = info.getParticleEffects(); - for ( std::list<std::string>::const_iterator i = particleEffects.begin(); - i != particleEffects.end(); - i++ - ) + if (mParticleEffects) { - controlParticle(particleEngine->addEffect((*i), 0, 0)); + const std::list<std::string> &particleEffects = info.getParticleEffects(); + for ( std::list<std::string>::const_iterator i = particleEffects.begin(); + i != particleEffects.end(); i++ + ) + { + controlParticle(particleEngine->addEffect((*i), 0, 0)); + } } + + mNameColor = 0xff2020; } Monster::~Monster() { if (mText) { - player_node->setTarget(0); + delete mText; + player_node->setTarget(NULL); } } @@ -99,9 +103,11 @@ Being::Type Monster::getType() const return MONSTER; } -void Monster::setAction(Uint8 action) +void Monster::setAction(Action action) { SpriteAction currentAction = ACTION_INVALID; + int rotation = 0; + std::string particleEffect; switch (action) { @@ -115,13 +121,34 @@ void Monster::setAction(Uint8 action) case ATTACK: currentAction = ACTION_ATTACK; mSprites[BASE_SPRITE]->reset(); + + //attack particle effect + particleEffect = getInfo().getAttackParticleEffect(); + if (!particleEffect.empty() && mParticleEffects) + { + switch (mDirection) + { + case DOWN: rotation = 0; break; + case LEFT: rotation = 90; break; + case UP: rotation = 180; break; + case RIGHT: rotation = 270; break; + default: break; + } + Particle *p; + p = particleEngine->addEffect( + particleEffect, 0, 0, rotation); + controlParticle(p); + } break; case STAND: - currentAction = ACTION_STAND; - break; + currentAction = ACTION_STAND; + break; case HURT: - // Not implemented yet - break; + // Not implemented yet + break; + case SIT: + // Also not implemented yet + break; } if (currentAction != ACTION_INVALID) @@ -164,13 +191,15 @@ const MonsterInfo &Monster::getInfo() const void Monster::showName(bool show) { - delete mText; + if (mText) + { + delete mText; + } if (show) { mText = new Text(getInfo().getName(), mPx + NAME_X_OFFSET, mPy + NAME_Y_OFFSET - getHeight(), - gcn::Graphics::CENTER, - gcn::Color(255, 64, 64)); + gcn::Graphics::CENTER, gcn::Color(255, 64, 64)); } else { |