From 2353f11b75e347c9662c7224f5b3abcd9189a6bb Mon Sep 17 00:00:00 2001 From: sniper Date: Tue, 10 Mar 2009 14:28:31 +0100 Subject: 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. --- src/being.cpp | 55 ++++++++++++++++++++++++------------------------------- 1 file changed, 24 insertions(+), 31 deletions(-) (limited to 'src/being.cpp') 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; -- cgit v1.2.3-70-g09d2