summaryrefslogtreecommitdiff
path: root/src/being.cpp
diff options
context:
space:
mode:
authorYohann Ferreira <yohann_dot_ferreira_at_orange_dot_efer>2011-04-29 01:21:45 +0200
committerAndrei Karas <akaras@inbox.ru>2011-05-01 23:45:51 +0300
commit6ff97aad8bf4af8e1a69665b3ad414042efada02 (patch)
treeed0f186c524146d0b68c082373b1053d84f51c16 /src/being.cpp
parentbba99b414167d9adb40622d8fc8c1e9dc814e956 (diff)
downloadmv-6ff97aad8bf4af8e1a69665b3ad414042efada02.tar.gz
mv-6ff97aad8bf4af8e1a69665b3ad414042efada02.tar.bz2
mv-6ff97aad8bf4af8e1a69665b3ad414042efada02.tar.xz
mv-6ff97aad8bf4af8e1a69665b3ad414042efada02.zip
Added customizable on-hit effects for characters.
This patch adds support for the following two parameters in weapon items: hit-effect-id: Effect triggered on the victim on normal hit. critical-hit-effect-id: Triggered on the victim on critical hit. (Specified in effects.xml) The patch also permits the use of custom defaults set in paths.xml by setting the following keys: (Paths are relative to the 'particles' key value, here.) hitEffectId: defaulted to effect id 26. criticalHitEffectId: defaulted to effect id 28. Resolves: Mana-mantis #337. Reviewed-by: bcs86 Conflicts: src/being.cpp src/resources/itemdb.cpp src/resources/iteminfo.h ManaPlus: adding missing checks.
Diffstat (limited to 'src/being.cpp')
-rw-r--r--src/being.cpp23
1 files changed, 19 insertions, 4 deletions
diff --git a/src/being.cpp b/src/being.cpp
index 3a7f08dda..eae4ebd66 100644
--- a/src/being.cpp
+++ b/src/being.cpp
@@ -606,10 +606,25 @@ void Being::takeDamage(Being *attacker, int amount, AttackType type)
if (effectManager)
{
- if (type != CRITICAL)
- effectManager->trigger(26, this);
+ // Init the particle effect path based on current
+ // weapon or default.
+ int hitEffectId = 0;
+ const ItemInfo *attackerWeapon = attacker->getEquippedWeapon();
+ if (attacker->getType() == PLAYER && attackerWeapon)
+ {
+ if (type != CRITICAL)
+ hitEffectId = attackerWeapon->getHitEffectId();
+ else
+ hitEffectId = attackerWeapon->getCriticalHitEffectId();
+ }
else
- effectManager->trigger(28, this);
+ {
+ if (type != CRITICAL)
+ hitEffectId = paths.getIntValue("hitEffectId");
+ else
+ hitEffectId = paths.getIntValue("criticalHitEffectId");
+ }
+ effectManager->trigger(hitEffectId, this);
}
}
}
@@ -624,7 +639,7 @@ void Being::handleAttack(Being *victim, int damage,
setAction(Being::ATTACK, 1);
if (getType() == PLAYER && mEquippedWeapon)
- fireMissile(victim, mEquippedWeapon->getMissileParticle());
+ fireMissile(victim, mEquippedWeapon->getMissileParticleFile());
else if (mInfo->getAttack(mAttackType))
fireMissile(victim, mInfo->getAttack(mAttackType)->missileParticle);