summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2015-01-06 20:08:17 +0300
committerAndrei Karas <akaras@inbox.ru>2015-01-06 20:08:17 +0300
commit7014a04cb0989b0e182f8a1346d33b005e200ad5 (patch)
tree6913b1b116431beb48943fac677ea65c046ea414 /src
parentb796051dc7ec88e1982ffbb2e488e908d839c1ef (diff)
downloadplus-7014a04cb0989b0e182f8a1346d33b005e200ad5.tar.gz
plus-7014a04cb0989b0e182f8a1346d33b005e200ad5.tar.bz2
plus-7014a04cb0989b0e182f8a1346d33b005e200ad5.tar.xz
plus-7014a04cb0989b0e182f8a1346d33b005e200ad5.zip
Move attacktype into separate file.
Diffstat (limited to 'src')
-rw-r--r--src/CMakeLists.txt1
-rw-r--r--src/Makefile.am1
-rw-r--r--src/being/being.cpp32
-rw-r--r--src/being/being.h26
-rw-r--r--src/enums/being/attacktype.h46
-rw-r--r--src/net/ea/beinghandler.cpp14
-rw-r--r--src/net/eathena/beinghandler.cpp28
7 files changed, 89 insertions, 59 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 89bdd6b38..2654f94bc 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -807,6 +807,7 @@ SET(SRCS
being/actorsprite.cpp
being/actorsprite.h
enums/being/actortype.h
+ enums/being/attacktype.h
enums/being/attributes.h
listeners/actorspritelistener.h
listeners/arrowslistener.cpp
diff --git a/src/Makefile.am b/src/Makefile.am
index 0658cf8c2..a0ec51227 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -929,6 +929,7 @@ manaplus_SOURCES += gui/widgets/avatarlistbox.cpp \
being/actorsprite.cpp \
being/actorsprite.h \
enums/being/actortype.h \
+ enums/being/attacktype.h \
enums/being/attributes.h \
listeners/actorspritelistener.h \
listeners/arrowslistener.cpp \
diff --git a/src/being/being.cpp b/src/being/being.cpp
index 1ef37c15a..1ca4cb700 100644
--- a/src/being/being.cpp
+++ b/src/being/being.cpp
@@ -554,7 +554,7 @@ void Being::setSpeech(const std::string &text, const std::string &channel,
}
void Being::takeDamage(Being *const attacker, const int amount,
- const AttackType type, const int attackId)
+ const AttackType::Type type, const int attackId)
{
if (!userPalette || !attacker)
return;
@@ -563,17 +563,17 @@ void Being::takeDamage(Being *const attacker, const int amount,
Font *font = nullptr;
// TRANSLATORS: hit or miss message in attacks
- const std::string damage = amount ? toString(amount) : type == FLEE ?
- _("dodge") : _("miss");
+ const std::string damage = amount ? toString(amount)
+ : type == AttackType::FLEE ? _("dodge") : _("miss");
const Color *color;
if (gui)
font = gui->getInfoParticleFont();
// Selecting the right color
- if (type == CRITICAL || type == FLEE)
+ if (type == AttackType::CRITICAL || type == AttackType::FLEE)
{
- if (type == CRITICAL)
+ if (type == AttackType::CRITICAL)
attacker->setCriticalHit(amount);
if (attacker == localPlayer)
@@ -655,7 +655,7 @@ void Being::takeDamage(Being *const attacker, const int amount,
BLOCK_END("Being::takeDamage1")
BLOCK_START("Being::takeDamage2")
- if (type != SKILL)
+ if (type != AttackType::SKILL)
attacker->updateHit(amount);
if (amount > 0)
@@ -707,7 +707,7 @@ void Being::takeDamage(Being *const attacker, const int amount,
if (effectManager)
{
const int hitEffectId = getHitEffect(attacker,
- MISS, attackId);
+ AttackType::MISS, attackId);
if (hitEffectId >= 0)
effectManager->trigger(hitEffectId, this);
}
@@ -716,7 +716,7 @@ void Being::takeDamage(Being *const attacker, const int amount,
}
int Being::getHitEffect(const Being *const attacker,
- const AttackType type, const int attackId) const
+ const AttackType::Type type, const int attackId) const
{
if (!effectManager)
return 0;
@@ -725,7 +725,7 @@ int Being::getHitEffect(const Being *const attacker,
// Init the particle effect path based on current
// weapon or default.
int hitEffectId = 0;
- if (type != SKILL)
+ if (type != AttackType::SKILL)
{
if (attacker)
{
@@ -733,9 +733,9 @@ int Being::getHitEffect(const Being *const attacker,
= attacker->getEquippedWeapon();
if (attackerWeapon && attacker->getType() == ActorType::Player)
{
- if (type == MISS)
+ if (type == AttackType::MISS)
hitEffectId = attackerWeapon->getMissEffectId();
- else if (type != CRITICAL)
+ else if (type != AttackType::CRITICAL)
hitEffectId = attackerWeapon->getHitEffectId();
else
hitEffectId = attackerWeapon->getCriticalHitEffectId();
@@ -748,9 +748,9 @@ int Being::getHitEffect(const Being *const attacker,
const Attack *const atk = info->getAttack(attackId);
if (atk)
{
- if (type == MISS)
+ if (type == AttackType::MISS)
hitEffectId = atk->mMissEffectId;
- else if (type != CRITICAL)
+ else if (type != AttackType::CRITICAL)
hitEffectId = atk->mHitEffectId;
else
hitEffectId = atk->mCriticalHitEffectId;
@@ -780,11 +780,11 @@ int Being::getHitEffect(const Being *const attacker,
return hitEffectId;
}
-int Being::getDefaultEffectId(const AttackType &type)
+int Being::getDefaultEffectId(const AttackType::Type &type)
{
- if (type == MISS)
+ if (type == AttackType::MISS)
return paths.getIntValue("missEffectId");
- else if (type != CRITICAL)
+ else if (type != AttackType::CRITICAL)
return paths.getIntValue("hitEffectId");
else
return paths.getIntValue("criticalHitEffectId");
diff --git a/src/being/being.h b/src/being/being.h
index 6b8a4dd52..fab70ff8f 100644
--- a/src/being/being.h
+++ b/src/being/being.h
@@ -29,6 +29,7 @@
#include "being/actorsprite.h"
+#include "enums/being/attacktype.h"
#include "enums/being/beingaction.h"
#include "enums/being/beingdirection.h"
#include "enums/being/gender.h"
@@ -90,25 +91,6 @@ class Being notfinal : public ActorSprite,
friend class BeingEquipBackend;
friend class LocalPlayer;
- enum AttackType
- {
- HIT = 0,
- PICKUP = 1,
- SIT = 2,
- STAND = 3,
- REFLECT = 4,
- SPLASH = 5,
- SKILL = 6,
- REPEATE = 7,
- MULTI = 8,
- MULTI_REFLECT = 9,
- CRITICAL = 10,
- FLEE = 11,
- TOUCH_SKILL = 12,
-// SKILL = 0xff,
- MISS = 0xffff // pseudo value for miss attacks
- };
-
enum Reachable
{
REACH_UNKNOWN = 0,
@@ -221,7 +203,7 @@ class Being notfinal : public ActorSprite,
* @param id skill id
*/
void takeDamage(Being *const attacker, const int damage,
- const AttackType type, const int attackId = 1);
+ const AttackType::Type type, const int attackId = 1);
/**
* Handles an attack of another being by this being.
@@ -823,7 +805,7 @@ class Being notfinal : public ActorSprite,
void recalcSpritesOrder();
int getHitEffect(const Being *const attacker,
- const AttackType type,
+ const AttackType::Type type,
const int attackId) const A_WARN_UNUSED;
Cursor::Cursor getHoverCursor() const A_WARN_UNUSED
@@ -942,7 +924,7 @@ class Being notfinal : public ActorSprite,
void createSpeechBubble();
- static int getDefaultEffectId(const AttackType &type);
+ static int getDefaultEffectId(const AttackType::Type &type);
BeingInfo *mInfo;
AnimatedSprite *mEmotionSprite;
diff --git a/src/enums/being/attacktype.h b/src/enums/being/attacktype.h
new file mode 100644
index 000000000..c040d66f9
--- /dev/null
+++ b/src/enums/being/attacktype.h
@@ -0,0 +1,46 @@
+/*
+ * The ManaPlus Client
+ * Copyright (C) 2004-2009 The Mana World Development Team
+ * Copyright (C) 2009-2010 The Mana Developers
+ * Copyright (C) 2011-2015 The ManaPlus Developers
+ *
+ * This file is part of The ManaPlus Client.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef ENUMS_BEING_ATTACKTYPE_H
+#define ENUMS_BEING_ATTACKTYPE_H
+
+namespace AttackType
+{
+ enum Type
+ {
+ HIT = 0,
+ PICKUP = 1,
+ SIT = 2,
+ STAND = 3,
+ REFLECT = 4,
+ SPLASH = 5,
+ SKILL = 6,
+ REPEATE = 7,
+ MULTI = 8,
+ MULTI_REFLECT = 9,
+ CRITICAL = 10,
+ FLEE = 11,
+ TOUCH_SKILL = 12,
+ MISS = 0xffff // pseudo value for miss attacks
+ };
+}
+#endif // ENUMS_BEING_ATTACKTYPE_H
diff --git a/src/net/ea/beinghandler.cpp b/src/net/ea/beinghandler.cpp
index 3c22ac62d..54f13472e 100644
--- a/src/net/ea/beinghandler.cpp
+++ b/src/net/ea/beinghandler.cpp
@@ -162,7 +162,7 @@ void BeingHandler::processSkillDamage(Net::MessageIn &msg)
if (srcBeing)
srcBeing->handleSkill(dstBeing, param1, id, level);
if (dstBeing)
- dstBeing->takeDamage(srcBeing, param1, Being::SKILL, id);
+ dstBeing->takeDamage(srcBeing, param1, AttackType::SKILL, id);
BLOCK_END("BeingHandler::processSkillDamage")
}
@@ -190,11 +190,11 @@ void BeingHandler::processBeingAction(Net::MessageIn &msg)
switch (type)
{
- case Being::HIT: // Damage
- case Being::CRITICAL: // Critical Damage
- case Being::MULTI: // Critical Damage
- case Being::REFLECT: // Reflected Damage
- case Being::FLEE: // Lucky Dodge
+ case AttackType::HIT: // Damage
+ case AttackType::CRITICAL: // Critical Damage
+ case AttackType::MULTI: // Critical Damage
+ case AttackType::REFLECT: // Reflected Damage
+ case AttackType::FLEE: // Lucky Dodge
if (srcBeing)
{
if (srcSpeed && srcBeing->getType() == ActorType::Player)
@@ -207,7 +207,7 @@ void BeingHandler::processBeingAction(Net::MessageIn &msg)
if (dstBeing)
{
dstBeing->takeDamage(srcBeing, param1,
- static_cast<Being::AttackType>(type));
+ static_cast<AttackType::Type>(type));
}
break;
diff --git a/src/net/eathena/beinghandler.cpp b/src/net/eathena/beinghandler.cpp
index f8d0c8954..ab8700227 100644
--- a/src/net/eathena/beinghandler.cpp
+++ b/src/net/eathena/beinghandler.cpp
@@ -1111,15 +1111,15 @@ void BeingHandler::processBeingAction2(Net::MessageIn &msg)
switch (type)
{
- case Being::HIT: // Damage
- case Being::CRITICAL: // Critical Damage
- case Being::MULTI: // Critical Damage
- case Being::MULTI_REFLECT:
- case Being::REFLECT: // Reflected Damage
- case Being::FLEE: // Lucky Dodge
- case Being::SPLASH:
- case Being::SKILL:
- case Being::REPEATE:
+ case AttackType::HIT: // Damage
+ case AttackType::CRITICAL: // Critical Damage
+ case AttackType::MULTI: // Critical Damage
+ case AttackType::MULTI_REFLECT:
+ case AttackType::REFLECT: // Reflected Damage
+ case AttackType::FLEE: // Lucky Dodge
+ case AttackType::SPLASH:
+ case AttackType::SKILL:
+ case AttackType::REPEATE:
if (srcBeing)
{
if (srcSpeed && srcBeing->getType() == ActorType::Player)
@@ -1132,17 +1132,17 @@ void BeingHandler::processBeingAction2(Net::MessageIn &msg)
if (dstBeing)
{
dstBeing->takeDamage(srcBeing, param1,
- static_cast<Being::AttackType>(type));
+ static_cast<AttackType::Type>(type));
}
break;
- case Being::PICKUP:
+ case AttackType::PICKUP:
break;
- case Being::TOUCH_SKILL:
+ case AttackType::TOUCH_SKILL:
break;
- case Being::SIT:
+ case AttackType::SIT:
if (srcBeing)
{
srcBeing->setAction(BeingAction::SIT, 0);
@@ -1155,7 +1155,7 @@ void BeingHandler::processBeingAction2(Net::MessageIn &msg)
}
break;
- case Being::STAND:
+ case AttackType::STAND:
if (srcBeing)
{
srcBeing->setAction(BeingAction::STAND, 0);