diff options
author | sniper <sniper@livecd.janhome.net> | 2009-03-10 14:28:31 +0100 |
---|---|---|
committer | Jared Adams <jaxad0127@gmail.com> | 2009-03-10 08:01:51 -0600 |
commit | cf49b996e41f6e28aa67fb2d6891c1b28e65d520 (patch) | |
tree | a12a5ee85064b2271e3c21554e89649ea07a3540 /src/being.cpp | |
parent | 7aeec98b0d2ff6c034c78e9ae6572179a808cfc5 (diff) | |
download | mana-cf49b996e41f6e28aa67fb2d6891c1b28e65d520.tar.gz mana-cf49b996e41f6e28aa67fb2d6891c1b28e65d520.tar.bz2 mana-cf49b996e41f6e28aa67fb2d6891c1b28e65d520.tar.xz mana-cf49b996e41f6e28aa67fb2d6891c1b28e65d520.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.cpp | 54 |
1 files changed, 37 insertions, 17 deletions
diff --git a/src/being.cpp b/src/being.cpp index 1e851b89..e6a8229f 100644 --- a/src/being.cpp +++ b/src/being.cpp @@ -225,26 +225,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; @@ -252,24 +255,41 @@ void Being::takeDamage(int amount) else { red = 255; - green = 50; - blue = 50; - } + green = 255; + blue = 0; + } + } + else if (getType() == MONSTER) + { + red = 0; + green = 100; + blue = 255; + } + else + { + red = 255; + green = 50; + blue = 50; } // Show damage number particleEngine->addTextSplashEffect(damage, red, green, blue, font, mPx + 16, mPy + 16, true); - effectManager->trigger(26, this); -} - -void Being::showCrit() -{ - effectManager->trigger(28, this); + if (amount > 0) + { + if (type != CRITICAL) + { + effectManager->trigger(26, this); + } + else + { + effectManager->trigger(28, this); + } + } } -void Being::handleAttack(Being *victim, int damage) +void Being::handleAttack(Being *victim, int damage, AttackType type) { setAction(Being::ATTACK); mFrame = 0; |