diff options
author | Chuck Miller <shadowmil@gmail.com> | 2010-02-10 23:46:49 -0500 |
---|---|---|
committer | Chuck Miller <shadowmil@gmail.com> | 2010-02-10 23:50:23 -0500 |
commit | 85e7f2a79477712bf3082cb82e6a73c51361abb0 (patch) | |
tree | c8a42adb06e0c5ba416bd30fcd1808c1e4f26ddc /src/being.cpp | |
parent | 3a761a242436e521c7fa8ef3746551ac7b746308 (diff) | |
download | mana-client-85e7f2a79477712bf3082cb82e6a73c51361abb0.tar.gz mana-client-85e7f2a79477712bf3082cb82e6a73c51361abb0.tar.bz2 mana-client-85e7f2a79477712bf3082cb82e6a73c51361abb0.tar.xz mana-client-85e7f2a79477712bf3082cb82e6a73c51361abb0.zip |
Adds missile-particle attribute to items and monster attacks
To use simply add something like: missile-particle="graphics/particles/arrow.particle.xml"
to the item's or monster's xml entry
This will only work on equipped weapons, and on specified monster attacks.
This patch also fixes a memory leak with target particles
Diffstat (limited to 'src/being.cpp')
-rw-r--r-- | src/being.cpp | 36 |
1 files changed, 22 insertions, 14 deletions
diff --git a/src/being.cpp b/src/being.cpp index 1c66f673..42fb2d4e 100644 --- a/src/being.cpp +++ b/src/being.cpp @@ -327,21 +327,9 @@ void Being::handleAttack(Being *victim, int damage, AttackType type) setAction(Being::ATTACK, 1); if (getType() == PLAYER && victim) { - if (mEquippedWeapon && mEquippedWeapon->getAttackType() == ACTION_ATTACK_BOW) + if (mEquippedWeapon) { - Particle *p = new Particle(NULL); - p->setLifetime(1000); - p->moveBy(Vector(0.0f, 0.0f, 32.0f)); - victim->controlParticle(p); - - Particle *p2 = particleEngine->addEffect("graphics/particles/arrow.particle.xml", - getPixelX(), getPixelY()); - if (p2) - { - p2->setLifetime(900); - p2->setDestination(p, 7, 0); - p2->setDieDistance(8); - } + fireMissile(victim, mEquippedWeapon->getMissileParticle()); } } if (Net::getNetworkType() == ServerInfo::EATHENA) @@ -398,6 +386,26 @@ void Being::controlParticle(Particle *particle) mChildParticleEffects.addLocally(particle); } +void Being::fireMissile(Being *victim, const std::string &particle) +{ + if (!victim || particle.empty()) + return; + + Particle *target = particleEngine->createChild(); + Particle *missile = target->addEffect(particle, getPixelX(), getPixelY()); + + if (missile) + { + target->setLifetime(2000); + target->moveBy(Vector(0.0f, 0.0f, 32.0f)); + victim->controlParticle(target); + + missile->setDestination(target, 7, 0); + missile->setDieDistance(8); + missile->setLifetime(900); + } +} + void Being::setAction(Action action, int attackType) { SpriteAction currentAction = ACTION_INVALID; |