diff options
author | Andrei Karas <akaras@inbox.ru> | 2012-10-05 21:33:44 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2012-10-05 21:33:44 +0300 |
commit | e6d7fca349c28eaf98d643325dc99dd9d3a53568 (patch) | |
tree | 84ac779d45a0094dde45d9a05039db41d568adbf /src/being.cpp | |
parent | a48638c5e9bfc04876661ea938eed4a3ab9e5c42 (diff) | |
download | mv-e6d7fca349c28eaf98d643325dc99dd9d3a53568.tar.gz mv-e6d7fca349c28eaf98d643325dc99dd9d3a53568.tar.bz2 mv-e6d7fca349c28eaf98d643325dc99dd9d3a53568.tar.xz mv-e6d7fca349c28eaf98d643325dc99dd9d3a53568.zip |
first part for adding mobs particle effects.
Based on mana commit b35aef2d924f03d85eb44a2465be5a745444eafd
by Yohann Ferreira
Diffstat (limited to 'src/being.cpp')
-rw-r--r-- | src/being.cpp | 71 |
1 files changed, 34 insertions, 37 deletions
diff --git a/src/being.cpp b/src/being.cpp index 1f637ef06..0df07870f 100644 --- a/src/being.cpp +++ b/src/being.cpp @@ -198,7 +198,6 @@ Being::Being(const int id, const Type type, const uint16_t subtype, mEmotion(0), mEmotionTime(0), mSpeechTime(0), - mAttackType(1), mAttackSpeed(350), mAction(STAND), mSubType(0xFFFF), @@ -645,9 +644,8 @@ void Being::takeDamage(Being *const attacker, const int amount, int hitEffectId = 0; if (type != SKILL) { - const ItemInfo *const attackerWeapon - = attacker->getEquippedWeapon(); - if (attacker->mType == PLAYER && attackerWeapon) + const ItemInfo *attackerWeapon = attacker->getEquippedWeapon(); + if (attackerWeapon && attacker->getType() == PLAYER) { if (type != CRITICAL) hitEffectId = attackerWeapon->getHitEffectId(); @@ -673,18 +671,18 @@ void Being::takeDamage(Being *const attacker, const int amount, } void Being::handleAttack(Being *const victim, const int damage, - const AttackType type A_UNUSED) + const int attackId) { if (!victim || !mInfo) return; if (this != player_node) - setAction(Being::ATTACK, 1); + setAction(Being::ATTACK, attackId); if (mType == PLAYER && mEquippedWeapon) fireMissile(victim, mEquippedWeapon->getMissileParticleFile()); - else if (mInfo->getAttack(mAttackType)) - fireMissile(victim, mInfo->getAttack(mAttackType)->missileParticle); + else if (mInfo->getAttack(attackId)) + fireMissile(victim, mInfo->getAttack(attackId)->mMissileParticle); #ifdef MANASERV_SUPPORT if (Net::getNetworkType() != ServerInfo::MANASERV) @@ -978,7 +976,7 @@ std::string Being::getSitAction() const } } -void Being::setAction(const Action &action, const int attackType A_UNUSED) +void Being::setAction(const Action &action, const int attackId) { std::string currentAction = SpriteAction::INVALID; @@ -1005,6 +1003,7 @@ void Being::setAction(const Action &action, const int attackType A_UNUSED) } break; case ATTACK: +// mAttackId = attackId; if (mEquippedWeapon) { currentAction = mEquippedWeapon->getAttackAction(); @@ -1012,43 +1011,39 @@ void Being::setAction(const Action &action, const int attackType A_UNUSED) } else { - mAttackType = attackType; - if (!mInfo || !mInfo->getAttack(attackType)) + if (!mInfo || !mInfo->getAttack(attackId)) break; - currentAction = mInfo->getAttack(attackType)->action; + currentAction = mInfo->getAttack(attackId)->mAction; reset(); -#ifdef MANASERV_SUPPORT - if (Net::getNetworkType() == ServerInfo::MANASERV - && mInfo->getAttack(attackType)) + //attack particle effect + if (Particle::enabled) { - //attack particle effect - std::string particleEffect = mInfo->getAttack(attackType) - ->particleEffect; - if (!particleEffect.empty() && Particle::enabled) + int effectId = mInfo->getAttack(attackId)->mEffectId; + + int rotation = 0; + switch (mSpriteDirection) { - int rotation = 0; - switch (mSpriteDirection) - { - case DIRECTION_DOWN: rotation = 0; break; - case DIRECTION_LEFT: rotation = 90; break; - case DIRECTION_UP: rotation = 180; break; - case DIRECTION_RIGHT: rotation = 270; break; - default: break; - } - if (particleEngine) - { - Particle *p = particleEngine->addEffect( - particleEffect, 0, 0, rotation); - if (p) - controlParticle(p); - } + case DIRECTION_DOWN: + rotation = 0; + break; + case DIRECTION_LEFT: + rotation = 90; + break; + case DIRECTION_UP: + rotation = 180; + break; + case DIRECTION_RIGHT: + rotation = 270; + break; + default: + break; } + if (effectManager) + effectManager->trigger(effectId, this, rotation); } -#endif } - break; case HURT: if (mInfo) @@ -1327,6 +1322,7 @@ void Being::logic() / mAttackSpeed; } +/* //attack particle effect if (mEquippedWeapon) { @@ -1363,6 +1359,7 @@ void Being::logic() particleEffect, 0, 0, rotation); controlParticle(p); } +*/ if (this == player_node && curFrame >= frameCount) nextTile(); |