summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/being.cpp23
-rw-r--r--src/being.h3
-rw-r--r--src/defaults.cpp2
-rw-r--r--src/resources/itemdb.cpp8
-rw-r--r--src/resources/iteminfo.h26
5 files changed, 54 insertions, 8 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);
diff --git a/src/being.h b/src/being.h
index 96c547e89..c83d0fb48 100644
--- a/src/being.h
+++ b/src/being.h
@@ -236,6 +236,9 @@ class Being : public ActorSprite, public ConfigListener
*/
virtual void handleAttack(Being *victim, int damage, AttackType type);
+ const ItemInfo *getEquippedWeapon() const
+ { return mEquippedWeapon; }
+
/**
* Returns the name of the being.
*/
diff --git a/src/defaults.cpp b/src/defaults.cpp
index 5249addd2..622740f61 100644
--- a/src/defaults.cpp
+++ b/src/defaults.cpp
@@ -244,6 +244,8 @@ DefaultsData* getPathsDefaults()
AddDEF(pathsData, "particles", "graphics/particles/");
AddDEF(pathsData, "levelUpEffectFile", "levelup.particle.xml");
AddDEF(pathsData, "portalEffectFile", "warparea.particle.xml");
+ AddDEF(pathsData, "hitEffectId", 26);
+ AddDEF(pathsData, "criticalHitEffectId", 28);
AddDEF(pathsData, "minimaps", "graphics/minimaps/");
AddDEF(pathsData, "maps", "maps/");
diff --git a/src/resources/itemdb.cpp b/src/resources/itemdb.cpp
index 59d7e951c..ab38e282e 100644
--- a/src/resources/itemdb.cpp
+++ b/src/resources/itemdb.cpp
@@ -226,6 +226,10 @@ void ItemDB::load()
int attackRange = XML::getProperty(node, "attack-range", 0);
std::string missileParticle = XML::getProperty(
node, "missile-particle", "");
+ int hitEffectId = XML::getProperty(node, "hit-effect-id",
+ paths.getIntValue("hitEffectId"));
+ int criticalEffectId = XML::getProperty(node, "critical-hit-effect-id",
+ paths.getIntValue("criticalHitEffectId"));
SpriteDisplay display;
display.image = image;
@@ -283,7 +287,9 @@ void ItemDB::load()
itemInfo->setWeight(weight);
itemInfo->setAttackAction(attackAction);
itemInfo->setAttackRange(attackRange);
- itemInfo->setMissileParticle(missileParticle);
+ itemInfo->setMissileParticleFile(missileParticle);
+ itemInfo->setHitEffectId(hitEffectId);
+ itemInfo->setCriticalHitEffectId(criticalEffectId);
itemInfo->setDrawBefore(parseSpriteName(drawBefore));
itemInfo->setDrawAfter(parseSpriteName(drawAfter));
itemInfo->setDrawPriority(drawPriority);
diff --git a/src/resources/iteminfo.h b/src/resources/iteminfo.h
index 8b276601c..01a4b5b9e 100644
--- a/src/resources/iteminfo.h
+++ b/src/resources/iteminfo.h
@@ -183,11 +183,25 @@ class ItemInfo
void setAttackAction(std::string attackAction);
// Handlers for seting and getting the string used for particles when attacking
- void setMissileParticle(std::string s) { mMissileParticle = s; }
+ void setMissileParticleFile(const std::string &s)
+ { mMissileParticleFile = s; }
- std::string getMissileParticle() const { return mMissileParticle; }
+ const std::string &getMissileParticleFile() const
+ { return mMissileParticleFile; }
- std::string getAttackAction() const
+ void setHitEffectId(int s)
+ { mHitEffectId = s; }
+
+ int getHitEffectId() const
+ { return mHitEffectId; }
+
+ void setCriticalHitEffectId(int s)
+ { mCriticalHitEffectId = s; }
+
+ int getCriticalHitEffectId() const
+ { return mCriticalHitEffectId; }
+
+ const std::string &getAttackAction() const
{ return mAttackAction; }
int getAttackRange() const
@@ -232,6 +246,9 @@ class ItemInfo
bool isRemoveItemId(int id) const;
+ /** Effects to be shown when weapon attacks - see also effects.xml */
+ std::string mMissileParticleFile;
+
int getReplaceToSpriteId(int id) const;
std::map<int, int> &addReplaceSprite(int sprite);
@@ -251,6 +268,9 @@ class ItemInfo
const std::string replaceColors(std::string str,
unsigned char color) const;
+ int mHitEffectId;
+ int mCriticalHitEffectId;
+
protected:
SpriteDisplay mDisplay; /**< Display info (like icon) */
std::string mName;