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 | |
parent | 7aeec98b0d2ff6c034c78e9ae6572179a808cfc5 (diff) | |
download | mana-client-cf49b996e41f6e28aa67fb2d6891c1b28e65d520.tar.gz mana-client-cf49b996e41f6e28aa67fb2d6891c1b28e65d520.tar.bz2 mana-client-cf49b996e41f6e28aa67fb2d6891c1b28e65d520.tar.xz mana-client-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')
-rw-r--r-- | src/being.cpp | 54 | ||||
-rw-r--r-- | src/being.h | 27 | ||||
-rw-r--r-- | src/localplayer.h | 8 | ||||
-rw-r--r-- | src/monster.cpp | 8 | ||||
-rw-r--r-- | src/monster.h | 13 | ||||
-rw-r--r-- | src/net/beinghandler.cpp | 15 |
6 files changed, 79 insertions, 46 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; diff --git a/src/being.h b/src/being.h index ef216841..3f753fcf 100644 --- a/src/being.h +++ b/src/being.h @@ -124,6 +124,15 @@ class Being : public Sprite NUM_SPEECH }; + enum AttackType + { + HIT = 0x00, + CRITICAL = 0x0a, + MULTI = 0x08, + REFLECT = 0x04, + FLEE = 0x0b + }; + /** * Directions, to be used as bitmask values */ @@ -172,22 +181,20 @@ class Being : public Sprite /** * Puts a damage bubble above this being. * - * @param amount The amount of damage. - */ - virtual void takeDamage(int amount); - - /** - * Puts a crit notification bubble above this being. + * @param attacker the attacking being + * @param damage the amount of damage recieved (0 means miss) + * @param type the attack type */ - virtual void showCrit(); + virtual void takeDamage(Being *attacker, int damage, AttackType type); /** * Handles an attack of another being by this being. * - * @param victim The attacked being. - * @param damage The amount of damage dealt (0 means miss). + * @param victim the victim being + * @param damage the amount of damage dealt (0 means miss) + * @param type the attack type */ - virtual void handleAttack(Being *victim, int damage); + virtual void handleAttack(Being *victim, int damage, AttackType type); /** * Returns the name of the being. diff --git a/src/localplayer.h b/src/localplayer.h index ce181c74..c94dba74 100644 --- a/src/localplayer.h +++ b/src/localplayer.h @@ -143,11 +143,11 @@ class LocalPlayer : public Player * displayed as soon as the player attacks, not when the server says * the player does. * - * @param victim The attacked being. - * @param damage The amount of damage dealt (0 means miss). + * @param victim the victim being + * @param damage the amount of damage dealt (0 means miss) + * @param type the attack type */ - virtual void handleAttack(Being *victim, int damage) {} - + virtual void handleAttack(Being *victim, int damage, AttackType type) {} /** * Returns the current target of the player. Returns 0 if no being is * currently targeted. diff --git a/src/monster.cpp b/src/monster.cpp index 2979e9fd..89d0953d 100644 --- a/src/monster.cpp +++ b/src/monster.cpp @@ -160,19 +160,19 @@ void Monster::setAction(Action action) } } -void Monster::handleAttack(Being *victim, int damage) +void Monster::handleAttack(Being *victim, int damage, AttackType type) { - Being::handleAttack(victim, damage); + Being::handleAttack(victim, damage, type); const MonsterInfo &mi = getInfo(); sound.playSfx(mi.getSound((damage > 0) ? MONSTER_EVENT_HIT : MONSTER_EVENT_MISS)); } -void Monster::takeDamage(int amount) +void Monster::takeDamage(Being *attacker, int amount, AttackType type) { if (amount > 0) sound.playSfx(getInfo().getSound(MONSTER_EVENT_HURT)); - Being::takeDamage(amount); + Being::takeDamage(attacker, amount, type); } Being::TargetCursorSize Monster::getTargetCursorSize() const diff --git a/src/monster.h b/src/monster.h index ab6f85df..7c16d178 100644 --- a/src/monster.h +++ b/src/monster.h @@ -47,17 +47,20 @@ class Monster : public Being * Handles an attack of another being by this monster. Plays a hit or * miss sound when appropriate. * - * @param victim The attacked being. - * @param damage The amount of damage dealt (0 means miss). + * @param victim the victim being + * @param damage the amount of damage dealt (0 means miss) + * @param type the attack type */ - virtual void handleAttack(Being *victim, int damage); + virtual void handleAttack(Being *victim, int damage, AttackType type); /** * Puts a damage bubble above this monster and plays the hurt sound * - * @param amount The amount of damage. + * @param attacker the attacking being + * @param damage the amount of damage recieved (0 means miss) + * @param type the attack type */ - virtual void takeDamage(int amount); + virtual void takeDamage(Being *attacker, int amount, AttackType type); /** * Returns the MonsterInfo, with static data about this monster. diff --git a/src/net/beinghandler.cpp b/src/net/beinghandler.cpp index 356d9509..b92e0e31 100644 --- a/src/net/beinghandler.cpp +++ b/src/net/beinghandler.cpp @@ -242,14 +242,17 @@ void BeingHandler::handleMessage(MessageIn *msg) switch (type) { - case 0x0a: // Critical Damage + case Being::HIT: // Damage + case Being::CRITICAL: // Critical Damage + case Being::MULTI: // Critical Damage + case Being::REFLECT: // Reflected Damage + case Being::FLEE: // Lucky Dodge if (dstBeing) - dstBeing->showCrit(); - case 0x00: // Damage - if (dstBeing) - dstBeing->takeDamage(param1); + dstBeing->takeDamage(srcBeing, param1, + (Being::AttackType)type); if (srcBeing) - srcBeing->handleAttack(dstBeing, param1); + srcBeing->handleAttack(dstBeing, param1, + (Being::AttackType)type); break; case 0x02: // Sit |