summaryrefslogtreecommitdiff
path: root/src/being.cpp
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2013-07-23 23:19:30 +0300
committerAndrei Karas <akaras@inbox.ru>2013-07-23 23:19:30 +0300
commit91075015ad4b5bd576c1a5668a11ea0227dd6bd1 (patch)
tree181df7013e6bfdd41cad4f2e9f18ad8944b79d04 /src/being.cpp
parent66f7df70fb03d487ae0c667adec3d5ad6e11721e (diff)
downloadplus-91075015ad4b5bd576c1a5668a11ea0227dd6bd1.tar.gz
plus-91075015ad4b5bd576c1a5668a11ea0227dd6bd1.tar.bz2
plus-91075015ad4b5bd576c1a5668a11ea0227dd6bd1.tar.xz
plus-91075015ad4b5bd576c1a5668a11ea0227dd6bd1.zip
add support for attacksky and attackwater actions.
Diffstat (limited to 'src/being.cpp')
-rw-r--r--src/being.cpp52
1 files changed, 48 insertions, 4 deletions
diff --git a/src/being.cpp b/src/being.cpp
index 63ffc0d2f..2fa5b7599 100644
--- a/src/being.cpp
+++ b/src/being.cpp
@@ -1047,6 +1047,52 @@ std::string Being::getMoveAction() const
}
}
+std::string Being::getWeaponAttackAction(const ItemInfo *const weapon) const
+{
+ if (!weapon)
+ return SpriteAction::ATTACK;
+
+ if (serverVersion < 0 || !weapon)
+ {
+ return weapon->getAttackAction();
+ }
+ else
+ {
+ if (mMap)
+ {
+ const unsigned char mask = mMap->getBlockMask(mX, mY);
+ if (mask & Map::BLOCKMASK_AIR)
+ return weapon->getSkyAttackAction();
+ else if (mask & Map::BLOCKMASK_WATER)
+ return weapon->getWaterAttackAction();
+ }
+ return weapon->getAttackAction();
+ }
+}
+
+std::string Being::getAttackAction(const Attack *const attack1) const
+{
+ if (!attack1)
+ return SpriteAction::ATTACK;
+
+ if (serverVersion < 0 || !attack1)
+ {
+ return attack1->mAction;
+ }
+ else
+ {
+ if (mMap)
+ {
+ const unsigned char mask = mMap->getBlockMask(mX, mY);
+ if (mask & Map::BLOCKMASK_AIR)
+ return attack1->mSkyAction;
+ else if (mask & Map::BLOCKMASK_WATER)
+ return attack1->mWaterAction;
+ }
+ return attack1->mAction;
+ }
+}
+
#define getSpriteAction(func, action) \
std::string Being::get##func##Action() const \
{ \
@@ -1104,8 +1150,7 @@ void Being::setAction(const Action &action, const int attackId)
case ATTACK:
if (mEquippedWeapon)
{
- // +++ for attack need 3 actions: normal, water, air
- currentAction = mEquippedWeapon->getAttackAction();
+ currentAction = getWeaponAttackAction(mEquippedWeapon);
reset();
}
else
@@ -1113,8 +1158,7 @@ void Being::setAction(const Action &action, const int attackId)
if (!mInfo || !mInfo->getAttack(attackId))
break;
- // +++ for attack need 3 actions: normal, water, air
- currentAction = mInfo->getAttack(attackId)->mAction;
+ currentAction = getAttackAction(mInfo->getAttack(attackId));
reset();
// attack particle effect