summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/being.cpp17
-rw-r--r--src/being.h2
-rw-r--r--src/resources/beinginfo.cpp7
-rw-r--r--src/resources/beinginfo.h6
-rw-r--r--src/resources/monsterdb.cpp10
5 files changed, 35 insertions, 7 deletions
diff --git a/src/being.cpp b/src/being.cpp
index 0df07870f..48c6cbe8b 100644
--- a/src/being.cpp
+++ b/src/being.cpp
@@ -510,7 +510,7 @@ void Being::setSpeech(const std::string &text, int time)
}
void Being::takeDamage(Being *const attacker, const int amount,
- const AttackType type, const int id)
+ const AttackType type, const int attackId)
{
if (!userPalette || !attacker)
return;
@@ -652,6 +652,19 @@ void Being::takeDamage(Being *const attacker, const int amount,
else
hitEffectId = attackerWeapon->getCriticalHitEffectId();
}
+ else if (attacker && attacker->getType() == MONSTER)
+ {
+ const BeingInfo *const info = attacker->getInfo();
+ if (info)
+ {
+ const Attack *attack = info->getAttack(attackId);
+
+ if (type != CRITICAL)
+ hitEffectId = attack->mHitEffectId;
+ else
+ hitEffectId = attack->mCriticalHitEffectId;
+ }
+ }
else
{
if (type != CRITICAL)
@@ -663,7 +676,7 @@ void Being::takeDamage(Being *const attacker, const int amount,
else
{
// move skills effects to +100000 in effects list
- hitEffectId = id + 100000;
+ hitEffectId = attackId + 100000;
}
effectManager->trigger(hitEffectId, this);
}
diff --git a/src/being.h b/src/being.h
index 95fff8b51..a3535afc2 100644
--- a/src/being.h
+++ b/src/being.h
@@ -258,7 +258,7 @@ class Being : public ActorSprite, public ConfigListener
* @param id skill id
*/
void takeDamage(Being *const attacker, const int damage,
- const AttackType type, const int id = 0);
+ const AttackType type, const int attackId = 0);
/**
* Handles an attack of another being by this being.
diff --git a/src/resources/beinginfo.cpp b/src/resources/beinginfo.cpp
index 992a43b5b..9ee0f3de9 100644
--- a/src/resources/beinginfo.cpp
+++ b/src/resources/beinginfo.cpp
@@ -30,7 +30,8 @@
#include "debug.h"
BeingInfo *BeingInfo::unknown = nullptr;
-Attack *BeingInfo::empty = new Attack(SpriteAction::ATTACK, -1, std::string());
+Attack *BeingInfo::empty = new Attack(SpriteAction::ATTACK,
+ -1, -1, -1, std::string());
BeingInfo::BeingInfo() :
mName(_("unnamed")),
@@ -114,12 +115,14 @@ const Attack *BeingInfo::getAttack(const int id) const
}
void BeingInfo::addAttack(const int id, std::string action, const int effectId,
+ const int hitEffectId, const int criticalHitEffectId,
const std::string &missileParticle)
{
if (mAttacks[id])
delete mAttacks[id];
- mAttacks[id] = new Attack(action, effectId, missileParticle);
+ mAttacks[id] = new Attack(action, effectId, hitEffectId,
+ criticalHitEffectId, missileParticle);
}
void BeingInfo::clear()
diff --git a/src/resources/beinginfo.h b/src/resources/beinginfo.h
index ceaed6c40..306ac637d 100644
--- a/src/resources/beinginfo.h
+++ b/src/resources/beinginfo.h
@@ -32,12 +32,17 @@ struct Attack final
{
std::string mAction;
int mEffectId;
+ int mHitEffectId;
+ int mCriticalHitEffectId;
std::string mMissileParticle;
Attack(const std::string &action, const int effectId,
+ const int hitEffectId, const int criticalHitEffectId,
const std::string &missileParticle) :
mAction(action),
mEffectId(effectId),
+ mHitEffectId(hitEffectId),
+ mCriticalHitEffectId(criticalHitEffectId),
mMissileParticle(missileParticle)
{
}
@@ -101,6 +106,7 @@ class BeingInfo final
const std::string &getSound(const SoundEvent event) const;
void addAttack(const int id, std::string action,
+ const int hitEffectId, const int criticalHitEffectId,
const int effectId,
const std::string &missileParticle);
diff --git a/src/resources/monsterdb.cpp b/src/resources/monsterdb.cpp
index f6352d8ec..d6aa53809 100644
--- a/src/resources/monsterdb.cpp
+++ b/src/resources/monsterdb.cpp
@@ -192,13 +192,19 @@ void MonsterDB::load()
const int id = XML::getProperty(spriteNode, "id", 0);
const int effectId = XML::getProperty(
spriteNode, "effect-id", -1);
+ int hitEffectId = XML::getProperty(spriteNode,
+ "hit-effect-id", paths.getIntValue("hitEffectId"));
+ int criticalHitEffectId = XML::getProperty(spriteNode,
+ "critical-hit-effect-id",
+ paths.getIntValue("criticalHitEffectId"));
+
const std::string spriteAction = XML::getProperty(
spriteNode, "action", "attack");
const std::string missileParticle = XML::getProperty(
spriteNode, "missile-particle", "");
- currentInfo->addAttack(id, spriteAction,
- effectId, missileParticle);
+ currentInfo->addAttack(id, spriteAction, hitEffectId,
+ criticalHitEffectId, effectId, missileParticle);
}
else if (xmlNameEqual(spriteNode, "particlefx"))
{