summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYohann Ferreira <yohann_dot_ferreira_at_orange_dot_efer>2011-06-04 00:50:23 +0200
committerYohann Ferreira <yohann_dot_ferreira_at_orange_dot_efer>2011-06-07 18:51:22 +0200
commitafa134640b2e2c7c0f28a54c8691545848795dd9 (patch)
treeb8c9f03debebc9a15de2a21f4d4a377247615c1d
parent9b1c970c70f30733d5d851b834a860365819409c (diff)
downloadmana-client-afa134640b2e2c7c0f28a54c8691545848795dd9.tar.gz
mana-client-afa134640b2e2c7c0f28a54c8691545848795dd9.tar.bz2
mana-client-afa134640b2e2c7c0f28a54c8691545848795dd9.tar.xz
mana-client-afa134640b2e2c7c0f28a54c8691545848795dd9.zip
Added hit effects on victims from monsters attacks.
Resolves: Mana-Mantis #336. Reviewed-by: Jaxad0127.
-rw-r--r--src/being.cpp12
-rw-r--r--src/being.h4
-rw-r--r--src/resources/beinginfo.cpp7
-rw-r--r--src/resources/beinginfo.h9
-rw-r--r--src/resources/monsterdb.cpp13
5 files changed, 36 insertions, 9 deletions
diff --git a/src/being.cpp b/src/being.cpp
index c9dd5b08..d9180bc9 100644
--- a/src/being.cpp
+++ b/src/being.cpp
@@ -309,7 +309,8 @@ void Being::setSpeech(const std::string &text, int time)
}
}
-void Being::takeDamage(Being *attacker, int amount, AttackType type)
+void Being::takeDamage(Being *attacker, int amount,
+ AttackType type, int attackId)
{
gcn::Font *font;
std::string damage = amount ? toString(amount) : type == FLEE ?
@@ -400,6 +401,15 @@ void Being::takeDamage(Being *attacker, int amount, AttackType type)
else
hitEffectId = attackerWeapon->getCriticalHitEffectId();
}
+ else if (attacker && attacker->getType() == MONSTER)
+ {
+ const Attack *attack = attacker->getInfo()->getAttack(attackId);
+
+ if (type != CRITICAL)
+ hitEffectId = attack->mHitEffectId;
+ else
+ hitEffectId = attack->mCriticalHitEffectId;
+ }
else
{
if (type != CRITICAL)
diff --git a/src/being.h b/src/being.h
index 55d49620..895506e8 100644
--- a/src/being.h
+++ b/src/being.h
@@ -162,8 +162,10 @@ class Being : public ActorSprite, public EventListener
* @param attacker the attacking being
* @param damage the amount of damage recieved (0 means miss)
* @param type the attack type
+ * @param attackId the attack id (used for monsters)
*/
- void takeDamage(Being *attacker, int damage, AttackType type);
+ void takeDamage(Being *attacker, int damage,
+ AttackType type, int attackId = 1);
/**
* Handles an attack of another being by this being.
diff --git a/src/resources/beinginfo.cpp b/src/resources/beinginfo.cpp
index 22651f6f..e6dc948e 100644
--- a/src/resources/beinginfo.cpp
+++ b/src/resources/beinginfo.cpp
@@ -90,17 +90,20 @@ const std::string &BeingInfo::getSound(SoundEvent event) const
const Attack *BeingInfo::getAttack(int id) const
{
- static Attack *empty = new Attack(SpriteAction::ATTACK, -1, std::string());
+ static Attack *empty = new Attack(SpriteAction::ATTACK, -1, -1, -1,
+ std::string());
Attacks::const_iterator i = mAttacks.find(id);
return (i == mAttacks.end()) ? empty : (*i).second;
}
void BeingInfo::addAttack(int id, std::string action, int effectId,
+ int hitEffectId, int criticalHitEffectId,
const std::string &missileParticleFilename)
{
if (mAttacks[id])
delete mAttacks[id];
- mAttacks[id] = new Attack(action, effectId, missileParticleFilename);
+ mAttacks[id] = new Attack(action, effectId, hitEffectId,
+ criticalHitEffectId, missileParticleFilename);
}
diff --git a/src/resources/beinginfo.h b/src/resources/beinginfo.h
index b4529b2f..fef698bb 100644
--- a/src/resources/beinginfo.h
+++ b/src/resources/beinginfo.h
@@ -33,14 +33,16 @@
struct Attack {
std::string mAction;
- int mEffectId;
+ int mEffectId, mHitEffectId, mCriticalHitEffectId;
std::string mMissileParticleFilename;
- Attack(std::string action, int effectId,
- std::string missileParticleFilename)
+ Attack(std::string action, int effectId, int hitEffectId,
+ int criticalHitEffectId, std::string missileParticleFilename)
{
mAction = action;
mEffectId = effectId;
+ mHitEffectId = hitEffectId;
+ mCriticalHitEffectId = criticalHitEffectId;
mMissileParticleFilename = missileParticleFilename;
}
};
@@ -96,6 +98,7 @@ class BeingInfo
const std::string &getSound(SoundEvent event) const;
void addAttack(int id, std::string action, int effectId,
+ int hitEffectId, int criticalHitEffectId,
const std::string &missileParticleFilename);
const Attack *getAttack(int id) const;
diff --git a/src/resources/monsterdb.cpp b/src/resources/monsterdb.cpp
index ca9b8e83..6d7fe9dc 100644
--- a/src/resources/monsterdb.cpp
+++ b/src/resources/monsterdb.cpp
@@ -125,12 +125,21 @@ void MonsterDB::load()
{
const int id = XML::getProperty(spriteNode, "id", 0);
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 missileParticleFilename =
+ XML::getProperty(spriteNode, "missile-particle", "");
+
const std::string spriteAction = XML::getProperty(spriteNode,
"action",
"attack");
- const std::string missileParticleFilename =
- XML::getProperty(spriteNode, "missile-particle", "");
+
currentInfo->addAttack(id, spriteAction, effectId,
+ hitEffectId, criticalHitEffectId,
missileParticleFilename);
}
else if (xmlStrEqual(spriteNode->name, BAD_CAST "particlefx"))