summaryrefslogtreecommitdiff
path: root/src/being/being.cpp
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2014-01-20 21:09:46 +0300
committerAndrei Karas <akaras@inbox.ru>2014-01-20 21:09:46 +0300
commit8f24400fc10658db9636e6cdd315504d75c71a5d (patch)
treef2f5a1094f6c48040b87238612d4042704846e40 /src/being/being.cpp
parent1f2dd660dad937a3c1f2a2dfc07b756965e4ddae (diff)
downloadmanaverse-8f24400fc10658db9636e6cdd315504d75c71a5d.tar.gz
manaverse-8f24400fc10658db9636e6cdd315504d75c71a5d.tar.bz2
manaverse-8f24400fc10658db9636e6cdd315504d75c71a5d.tar.xz
manaverse-8f24400fc10658db9636e6cdd315504d75c71a5d.zip
add attack action for pets.
New pets db attributes: attackOffsetX attackOffsetY attaclDirectionType
Diffstat (limited to 'src/being/being.cpp')
-rw-r--r--src/being/being.cpp41
1 files changed, 39 insertions, 2 deletions
diff --git a/src/being/being.cpp b/src/being/being.cpp
index aa2b875af..dbe4d7350 100644
--- a/src/being/being.cpp
+++ b/src/being/being.cpp
@@ -134,6 +134,8 @@ Being::Being(const int id, const Type type, const uint16_t subtype,
mAttackSpeed(350),
mLevel(0),
mAttackRange(1),
+ mLastAttackX(0),
+ mLastAttackY(0),
mGender(GENDER_UNSPECIFIED),
mAction(STAND),
mSubType(0xFFFF),
@@ -760,6 +762,9 @@ void Being::handleAttack(Being *const victim, const int damage,
if (this != player_node)
setAction(Being::ATTACK, attackId);
+ mLastAttackX = victim->getTileX();
+ mLastAttackY = victim->getTileY();
+
if (mType == PLAYER && mEquippedWeapon)
fireMissile(victim, mEquippedWeapon->getMissileParticleFile());
else if (mInfo->getAttack(attackId))
@@ -1720,14 +1725,24 @@ void Being::petLogic()
return;
}
}
- if (mAction == STAND)
+ if (mOwner->getCurrentAction() != ATTACK)
+ {
+ if (mAction == ATTACK)
+ setAction(STAND, 0);
+ }
+ else
+ {
+ if (mAction == STAND || mAction == ATTACK)
+ setAction(ATTACK, 0);
+ }
+
+ if (mAction == STAND || mAction == ATTACK)
{
int directionType = 0;
switch (mOwner->getCurrentAction())
{
case STAND:
case MOVE:
- case ATTACK:
case HURT:
case SPAWN:
default:
@@ -1739,6 +1754,9 @@ void Being::petLogic()
case DEAD:
directionType = mInfo->getDeadDirectionType();
break;
+ case ATTACK:
+ directionType = mInfo->getAttackDirectionType();
+ break;
}
int newDir = 0;
@@ -1773,6 +1791,21 @@ void Being::petLogic()
else if (dstY < dstY0)
newDir |= UP;
break;
+
+ case 4:
+ {
+ const int dstX2 = mOwner->getLastAttackX();
+ const int dstY2 = mOwner->getLastAttackY();
+ if (dstX > dstX2)
+ newDir |= LEFT;
+ else if (dstX < dstX2)
+ newDir |= RIGHT;
+ if (dstY > dstY2)
+ newDir |= UP;
+ else if (dstY < dstY2)
+ newDir |= DOWN;
+ break;
+ }
}
if (newDir && newDir != getDirection())
setDirection(newDir);
@@ -3337,6 +3370,10 @@ void Being::fixPetSpawnPos(int &dstX, int &dstY) const
break;
case ATTACK:
+ offsetX1 = mInfo->getAttackOffsetX();
+ offsetY1 = mInfo->getAttackOffsetY();
+ break;
+
case SPAWN:
case HURT:
case STAND: