summaryrefslogtreecommitdiff
path: root/src/being.cpp
diff options
context:
space:
mode:
authorsniper <sniper@livecd.janhome.net>2009-03-10 14:28:31 +0100
committerIra Rice <irarice@gmail.com>2009-03-10 09:02:53 -0600
commit2353f11b75e347c9662c7224f5b3abcd9189a6bb (patch)
treebf4c6b7dca4cab6b6bacf5e32c51518cbd327ae5 /src/being.cpp
parent1570fb33d5909786ef2997246ada7c46dd6de9e4 (diff)
downloadmana-2353f11b75e347c9662c7224f5b3abcd9189a6bb.tar.gz
mana-2353f11b75e347c9662c7224f5b3abcd9189a6bb.tar.bz2
mana-2353f11b75e347c9662c7224f5b3abcd9189a6bb.tar.xz
mana-2353f11b75e347c9662c7224f5b3abcd9189a6bb.zip
Extended hit type handling
The client can now differentiate between the following hit types: - hit (normal) - critical (full attack) - multi (more than one hit at once, currently not used) - reflect (reflected damage, currently not used) - flee (dodging criticals) The Being's showCrit method is now merged into takeDamage. Being's takeDamage and handleAttack now both get the opponent, the amount of damage and the attack type as parameter.
Diffstat (limited to 'src/being.cpp')
-rw-r--r--src/being.cpp55
1 files changed, 24 insertions, 31 deletions
diff --git a/src/being.cpp b/src/being.cpp
index c31dae6d..ad6b2dea 100644
--- a/src/being.cpp
+++ b/src/being.cpp
@@ -219,26 +219,29 @@ void Being::setSpeech(const std::string &text, int time)
mSpeechTime = time <= SPEECH_MAX_TIME ? time : SPEECH_MAX_TIME;
}
-void Being::takeDamage(int amount)
+void Being::takeDamage(Being *attacker, int amount, AttackType type)
{
gcn::Font *font;
- std::string damage = amount ? toString(amount) : "miss";
+ std::string damage = amount ? toString(amount) : type == FLEE ?
+ "dodge" : "miss";
int red, green, blue;
font = gui->getInfoParticleFont();
// Selecting the right color
- if (damage == "miss")
+ if (type == CRITICAL || type == FLEE)
{
red = 255;
- green = 255;
+ green = 128;
blue = 0;
}
- else
- {
- if (getType() == MONSTER)
+ else if (!amount)
+ {
+ if (attacker == player_node)
{
+ // This is intended to be the wrong direction to visually
+ // differentiate between hits and misses
red = 0;
green = 100;
blue = 255;
@@ -246,27 +249,11 @@ void Being::takeDamage(int amount)
else
{
red = 255;
- green = 50;
- blue = 50;
- }
- }
-
- // Show damage number
- particleEngine->addTextSplashEffect(damage, red, green, blue, font,
- mPx + 16, mPy + 16, true);
-}
-
-void Being::showCrit()
-{
- gcn::Font *font;
- std::string text = "crit!";
-
- int red, green, blue;
-
- font = gui->getInfoParticleFont();
-
- // Selecting the right color
- if (getType() == MONSTER)
+ green = 255;
+ blue = 0;
+ }
+ }
+ else if (getType() == MONSTER)
{
red = 0;
green = 100;
@@ -279,12 +266,18 @@ void Being::showCrit()
blue = 50;
}
- // Show crit notice
- particleEngine->addTextSplashEffect(text, red, green, blue, font,
+ if (amount > 0 && type == CRITICAL)
+ {
+ particleEngine->addTextSplashEffect("crit!", red, green, blue, font,
+ mPx + 16, mPy + 16, true);
+ }
+
+ // Show damage number
+ particleEngine->addTextSplashEffect(damage, red, green, blue, font,
mPx + 16, mPy + 16, true);
}
-void Being::handleAttack(Being *victim, int damage)
+void Being::handleAttack(Being *victim, int damage, AttackType type)
{
setAction(Being::ATTACK);
mFrame = 0;