summaryrefslogtreecommitdiff
path: root/src/being.cpp
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2012-10-06 03:54:00 +0300
committerAndrei Karas <akaras@inbox.ru>2012-10-06 03:54:00 +0300
commit4fb8f9f0905038f3180f108ec56b2a326ceb3483 (patch)
tree94b221f6bc81e07d565d2828dac078f471854b81 /src/being.cpp
parentdf9a705c331da29cb0582539a817f68c79d4f267 (diff)
downloadmanaplus-4fb8f9f0905038f3180f108ec56b2a326ceb3483.tar.gz
manaplus-4fb8f9f0905038f3180f108ec56b2a326ceb3483.tar.bz2
manaplus-4fb8f9f0905038f3180f108ec56b2a326ceb3483.tar.xz
manaplus-4fb8f9f0905038f3180f108ec56b2a326ceb3483.zip
Add particle effect miss-effect-id to items and monsters.
Diffstat (limited to 'src/being.cpp')
-rw-r--r--src/being.cpp111
1 files changed, 68 insertions, 43 deletions
diff --git a/src/being.cpp b/src/being.cpp
index 89134bd0b..ad867ffbc 100644
--- a/src/being.cpp
+++ b/src/being.cpp
@@ -635,67 +635,92 @@ void Being::takeDamage(Being *const attacker, const int amount,
updateName();
}
else if (mType == PLAYER && socialWindow && getName() != "")
+ {
socialWindow->updateAvatar(getName());
+ }
if (effectManager)
{
- // Init the particle effect path based on current
- // weapon or default.
- int hitEffectId = 0;
- if (type != SKILL)
+ int hitEffectId = getHitEffect(attacker, type, attackId);
+ if (hitEffectId >= 0)
+ effectManager->trigger(hitEffectId, this);
+ }
+ }
+ else
+ {
+ if (effectManager)
+ {
+ int hitEffectId = getHitEffect(attacker,
+ MISS, attackId);
+ if (hitEffectId >= 0)
+ effectManager->trigger(hitEffectId, this);
+ }
+ }
+}
+
+int Being::getHitEffect(const Being *const attacker,
+ const AttackType type, const int attackId) const
+{
+ if (!effectManager)
+ return 0;
+
+ // Init the particle effect path based on current
+ // weapon or default.
+ int hitEffectId = 0;
+ if (type != SKILL)
+ {
+ const ItemInfo *attackerWeapon = attacker->getEquippedWeapon();
+ if (attackerWeapon && attacker->getType() == PLAYER)
+ {
+ if (type == MISS)
+ hitEffectId = attackerWeapon->getMissEffectId();
+ else if (type != CRITICAL)
+ hitEffectId = attackerWeapon->getHitEffectId();
+ else
+ hitEffectId = attackerWeapon->getCriticalHitEffectId();
+ }
+ else if (attacker && attacker->getType() == MONSTER)
+ {
+ const BeingInfo *const info = attacker->getInfo();
+ if (info)
{
- const ItemInfo *attackerWeapon = attacker->getEquippedWeapon();
- if (attackerWeapon && attacker->getType() == PLAYER)
+ const Attack *atk = info->getAttack(attackId);
+ if (atk)
{
- if (type != CRITICAL)
- hitEffectId = attackerWeapon->getHitEffectId();
+ if (type == MISS)
+ hitEffectId = atk->mMissEffectId;
+ else if (type != CRITICAL)
+ hitEffectId = atk->mHitEffectId;
else
- hitEffectId = attackerWeapon->getCriticalHitEffectId();
- }
- else if (attacker && attacker->getType() == MONSTER)
- {
- const BeingInfo *const info = attacker->getInfo();
- if (info)
- {
- const Attack *atk = info->getAttack(attackId);
- if (atk)
- {
- if (type != CRITICAL)
- hitEffectId = atk->mHitEffectId;
- else
- hitEffectId = atk->mCriticalHitEffectId;
- }
- else
- {
- if (type != CRITICAL)
- {
- hitEffectId = paths.getIntValue("hitEffectId");
- }
- else
- {
- hitEffectId = paths.getIntValue(
- "criticalHitEffectId");
- }
- }
- }
+ hitEffectId = atk->mCriticalHitEffectId;
}
else
{
- if (type != CRITICAL)
+ if (type == MISS)
+ hitEffectId = paths.getIntValue("missEffectId");
+ else if (type != CRITICAL)
hitEffectId = paths.getIntValue("hitEffectId");
else
hitEffectId = paths.getIntValue("criticalHitEffectId");
}
}
+ }
+ else
+ {
+ if (type == MISS)
+ hitEffectId = paths.getIntValue("missEffectId");
+ else if (type != CRITICAL)
+ hitEffectId = paths.getIntValue("hitEffectId");
else
- {
- // move skills effects to +100000 in effects list
- hitEffectId = attackId + 100000;
- }
- if (effectManager && hitEffectId >= 0)
- effectManager->trigger(hitEffectId, this);
+ hitEffectId = paths.getIntValue("criticalHitEffectId");
}
}
+ else
+ {
+ // move skills effects to +100000 in effects list
+ hitEffectId = attackId + 100000;
+ }
+ return hitEffectId;
}
void Being::handleAttack(Being *const victim, const int damage,