diff options
author | Ira Rice <irarice@gmail.com> | 2008-10-13 09:34:46 +0000 |
---|---|---|
committer | Ira Rice <irarice@gmail.com> | 2008-10-13 09:34:46 +0000 |
commit | a4d2f2c0373848fa8a886c1dddc6247b81527df3 (patch) | |
tree | b4d0f0dcab4bd9ff06a4cd0613e26f61fffb45ce /src | |
parent | 1c337aae30b334d99a5ec81269f2c6d35b8004ea (diff) | |
download | mana-client-a4d2f2c0373848fa8a886c1dddc6247b81527df3.tar.gz mana-client-a4d2f2c0373848fa8a886c1dddc6247b81527df3.tar.bz2 mana-client-a4d2f2c0373848fa8a886c1dddc6247b81527df3.tar.xz mana-client-a4d2f2c0373848fa8a886c1dddc6247b81527df3.zip |
Added mob particle attack effects to mobs. Inspired by the TMW patch in
their
trunk client.
Diffstat (limited to 'src')
-rw-r--r-- | src/monster.cpp | 21 | ||||
-rw-r--r-- | src/particle.cpp | 4 | ||||
-rw-r--r-- | src/particle.h | 4 | ||||
-rw-r--r-- | src/particleemitter.cpp | 4 | ||||
-rw-r--r-- | src/particleemitter.h | 2 | ||||
-rw-r--r-- | src/resources/monsterdb.cpp | 6 | ||||
-rw-r--r-- | src/resources/monsterinfo.h | 8 |
7 files changed, 43 insertions, 6 deletions
diff --git a/src/monster.cpp b/src/monster.cpp index 2b6fadce..61f1f5c3 100644 --- a/src/monster.cpp +++ b/src/monster.cpp @@ -46,6 +46,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(); @@ -103,6 +104,8 @@ Being::Type Monster::getType() const void Monster::setAction(Action action) { SpriteAction currentAction = ACTION_INVALID; + int rotation = 0; + std::string particleEffect; switch (action) { @@ -116,6 +119,24 @@ void Monster::setAction(Action action) case ATTACK: currentAction = ACTION_ATTACK; mSprites[BASE_SPRITE]->reset(); + + //attack particle effect + particleEffect = getInfo().getAttackParticleEffect(); + if (particleEffect != "") + { + 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; diff --git a/src/particle.cpp b/src/particle.cpp index 8591838f..703b34c3 100644 --- a/src/particle.cpp +++ b/src/particle.cpp @@ -226,7 +226,7 @@ Particle::update() Particle* Particle::addEffect(const std::string &particleEffectFile, - int pixelX, int pixelY) + int pixelX, int pixelY, int rotation) { Particle *newParticle = NULL; @@ -290,7 +290,7 @@ Particle::addEffect(const std::string &particleEffectFile, continue; ParticleEmitter *newEmitter; - newEmitter = new ParticleEmitter(emitterNode, newParticle, mMap); + newEmitter = new ParticleEmitter(emitterNode, newParticle, mMap, rotation); newParticle->addEmitter(newEmitter); } diff --git a/src/particle.h b/src/particle.h index f281864d..a21fe88b 100644 --- a/src/particle.h +++ b/src/particle.h @@ -109,7 +109,7 @@ class Particle : public Sprite */ Particle* addEffect(const std::string &particleEffectFile, - int pixelX, int pixelY); + int pixelX, int pixelY, int rotation = 0); /** * Creates a standalone text particle. @@ -318,7 +318,7 @@ class Particle : public Sprite // follow-point particles Particle *mTarget; /**< The particle that attracts this particle*/ - float mAcceleration; /**< Acceleration towards the target particle in pixels per game-tick²*/ + float mAcceleration; /**< Acceleration towards the target particle in pixels per game-tick�*/ float mInvDieDistance; /**< Distance in pixels from the target particle that causes the destruction of the particle*/ float mMomentum; /**< How much speed the particle retains after each game tick*/ }; diff --git a/src/particleemitter.cpp b/src/particleemitter.cpp index 816a5d28..08944cdd 100644 --- a/src/particleemitter.cpp +++ b/src/particleemitter.cpp @@ -38,7 +38,7 @@ #define SIN45 0.707106781f #define DEG_RAD_FACTOR 0.017453293f -ParticleEmitter::ParticleEmitter(xmlNodePtr emitterNode, Particle *target, Map *map): +ParticleEmitter::ParticleEmitter(xmlNodePtr emitterNode, Particle *target, Map *map, int rotation): mOutputPauseLeft(0), mParticleImage(0) { @@ -102,7 +102,9 @@ ParticleEmitter::ParticleEmitter(xmlNodePtr emitterNode, Particle *target, Map * else if (name == "horizontal-angle") { mParticleAngleHorizontal = readMinMax(propertyNode, 0.0f); + mParticleAngleHorizontal.minVal += rotation; mParticleAngleHorizontal.minVal *= DEG_RAD_FACTOR; + mParticleAngleHorizontal.maxVal += rotation; mParticleAngleHorizontal.maxVal *= DEG_RAD_FACTOR; } else if (name == "vertical-angle") diff --git a/src/particleemitter.h b/src/particleemitter.h index 5cf3fd46..c237c1ba 100644 --- a/src/particleemitter.h +++ b/src/particleemitter.h @@ -45,7 +45,7 @@ class ParticleEmitter /** * Constructor. */ - ParticleEmitter(xmlNodePtr emitterNode, Particle *target, Map *map); + ParticleEmitter(xmlNodePtr emitterNode, Particle *target, Map *map, int rotation = 0); /** * Copy Constructor (necessary for reference counting of particle images) diff --git a/src/resources/monsterdb.cpp b/src/resources/monsterdb.cpp index 73e9d666..8d8dd133 100644 --- a/src/resources/monsterdb.cpp +++ b/src/resources/monsterdb.cpp @@ -126,6 +126,12 @@ MonsterDB::load() } } + if (xmlStrEqual(spriteNode->name, BAD_CAST "attack")) + { + std::string event = XML::getProperty(spriteNode, "particle-effect", ""); + currentInfo->addAttackParticleEffect(event); + } + if (xmlStrEqual(spriteNode->name, BAD_CAST "particlefx")) { currentInfo->addParticleEffect( diff --git a/src/resources/monsterinfo.h b/src/resources/monsterinfo.h index 2f690756..c5345bd8 100644 --- a/src/resources/monsterinfo.h +++ b/src/resources/monsterinfo.h @@ -87,11 +87,19 @@ class MonsterInfo std::string getSound(MonsterSoundEvent event) const; + std::string + getAttackParticleEffect() const { return mAttackParticle; } + + void + addAttackParticleEffect(const std::string &particleEffect) + { mAttackParticle = particleEffect; } + const std::list<std::string>& getParticleEffects() const { return mParticleEffects; } private: std::string mName; + std::string mAttackParticle; std::list<std::string> mSprites; Being::TargetCursorSize mTargetCursorSize; std::map<MonsterSoundEvent, std::vector<std::string>* > mSounds; |