summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2013-12-25 14:54:25 +0300
committerAndrei Karas <akaras@inbox.ru>2013-12-25 14:54:25 +0300
commit3e43345f804886a3a6ed7c0e378612612de4f4a5 (patch)
treeea7e36388a7ac1cc57ced5b33651b919302b3804
parentdb67d909cfa5d6a53552bbdb80c215fb382f00d5 (diff)
downloadplus-3e43345f804886a3a6ed7c0e378612612de4f4a5.tar.gz
plus-3e43345f804886a3a6ed7c0e378612612de4f4a5.tar.bz2
plus-3e43345f804886a3a6ed7c0e378612612de4f4a5.tar.xz
plus-3e43345f804886a3a6ed7c0e378612612de4f4a5.zip
add support for pet offsets if owner is sitting.
-rw-r--r--src/being/being.cpp29
-rw-r--r--src/being/being.h2
-rw-r--r--src/net/ea/beinghandler.cpp1
-rw-r--r--src/net/eathena/beinghandler.cpp1
-rw-r--r--src/net/tmwa/beinghandler.cpp1
-rw-r--r--src/resources/beinginfo.cpp2
-rw-r--r--src/resources/beinginfo.h14
-rw-r--r--src/resources/db/petdb.cpp4
8 files changed, 49 insertions, 5 deletions
diff --git a/src/being/being.cpp b/src/being/being.cpp
index 00ef62e0a..e93675e5a 100644
--- a/src/being/being.cpp
+++ b/src/being/being.cpp
@@ -1698,8 +1698,11 @@ void Being::petLogic()
dstX = dstX0;
}
}
- setPath(mMap->findPath(mX, mY, dstX, dstY, walkMask));
- Net::getPetHandler()->move(mOwner, mX, mY, dstX, dstY);
+ if (mX != dstX || mY != dstY)
+ {
+ setPath(mMap->findPath(mX, mY, dstX, dstY, walkMask));
+ Net::getPetHandler()->move(mOwner, mX, mY, dstX, dstY);
+ }
}
}
@@ -3187,13 +3190,30 @@ void Being::updatePets()
}
}
+void Being::updatePet()
+{
+ if (mPet)
+ mPet->petLogic();
+}
+
void Being::fixPetSpawnPos(int &dstX, int &dstY) const
{
if (!mInfo || !mOwner)
return;
- const int offsetX1 = mInfo->getTargetOffsetX();
- const int offsetY1 = mInfo->getTargetOffsetY();
+ int offsetX1;
+ int offsetY1;
+ if (mOwner->getCurrentAction() == SIT)
+ {
+ offsetX1 = mInfo->getSitOffsetX();
+ offsetY1 = mInfo->getSitOffsetY();
+ }
+ else
+ {
+ offsetX1 = mInfo->getTargetOffsetX();
+ offsetY1 = mInfo->getTargetOffsetY();
+ }
+
int offsetX = offsetX1;
int offsetY = offsetY1;
switch (mOwner->getDirection())
@@ -3214,7 +3234,6 @@ void Being::fixPetSpawnPos(int &dstX, int &dstY) const
case DOWN:
break;
}
- logger->log("fix offset: %d,%d", offsetX, offsetY);
dstX += offsetX;
dstY += offsetY;
}
diff --git a/src/being/being.h b/src/being/being.h
index e8bc7da37..99e9dda45 100644
--- a/src/being/being.h
+++ b/src/being/being.h
@@ -881,6 +881,8 @@ class Being : public ActorSprite, public ConfigListener
void updatePets();
+ void updatePet();
+
void fixPetSpawnPos(int &dstX, int &dstY) const;
Being *getPet()
diff --git a/src/net/ea/beinghandler.cpp b/src/net/ea/beinghandler.cpp
index 0a864bbac..3fbfdd2d7 100644
--- a/src/net/ea/beinghandler.cpp
+++ b/src/net/ea/beinghandler.cpp
@@ -515,6 +515,7 @@ void BeingHandler::processBeingAction(Net::MessageIn &msg) const
if (srcBeing)
{
srcBeing->setAction(Being::SIT, 0);
+ srcBeing->updatePet();
if (srcBeing->getType() == Being::PLAYER)
{
srcBeing->setMoveTime();
diff --git a/src/net/eathena/beinghandler.cpp b/src/net/eathena/beinghandler.cpp
index 108e6b50f..196196a07 100644
--- a/src/net/eathena/beinghandler.cpp
+++ b/src/net/eathena/beinghandler.cpp
@@ -586,6 +586,7 @@ void BeingHandler::processPlayerMoveUpdate(Net::MessageIn &msg,
case 2:
dstBeing->setAction(Being::SIT, 0);
+ dstBeing->updatePet();
player_node->imitateAction(dstBeing, Being::SIT);
break;
diff --git a/src/net/tmwa/beinghandler.cpp b/src/net/tmwa/beinghandler.cpp
index cfb25fa49..de2a25946 100644
--- a/src/net/tmwa/beinghandler.cpp
+++ b/src/net/tmwa/beinghandler.cpp
@@ -612,6 +612,7 @@ void BeingHandler::processPlayerMoveUpdate(Net::MessageIn &msg,
case 2:
dstBeing->setAction(Being::SIT, 0);
+ dstBeing->updatePet();
player_node->imitateAction(dstBeing, Being::SIT);
break;
diff --git a/src/resources/beinginfo.cpp b/src/resources/beinginfo.cpp
index 752b9a5dc..fc23bf231 100644
--- a/src/resources/beinginfo.cpp
+++ b/src/resources/beinginfo.cpp
@@ -64,6 +64,8 @@ BeingInfo::BeingInfo() :
mFollowDist(1),
mWarpDist(11),
mWalkSpeed(0),
+ mSitOffsetX(0),
+ mSitOffsetY(0),
mStaticMaxHP(false),
mTargetSelection(true)
{
diff --git a/src/resources/beinginfo.h b/src/resources/beinginfo.h
index d27704aaf..769f796f6 100644
--- a/src/resources/beinginfo.h
+++ b/src/resources/beinginfo.h
@@ -248,6 +248,18 @@ class BeingInfo final
int getWarpDist() const A_WARN_UNUSED
{ return mWarpDist; }
+ void setSitOffsetX(const int n)
+ { mSitOffsetX = n; }
+
+ int getSitOffsetX() const A_WARN_UNUSED
+ { return mSitOffsetX; }
+
+ void setSitOffsetY(const int n)
+ { mSitOffsetY = n; }
+
+ int getSitOffsetY() const A_WARN_UNUSED
+ { return mSitOffsetY; }
+
void setColorsList(const std::string &name);
std::string getColor(const int idx) const A_WARN_UNUSED;
@@ -282,6 +294,8 @@ class BeingInfo final
int mFollowDist;
int mWarpDist;
int mWalkSpeed;
+ int mSitOffsetX;
+ int mSitOffsetY;
bool mStaticMaxHP;
bool mTargetSelection;
};
diff --git a/src/resources/db/petdb.cpp b/src/resources/db/petdb.cpp
index d50c44dc7..7c84b006b 100644
--- a/src/resources/db/petdb.cpp
+++ b/src/resources/db/petdb.cpp
@@ -96,6 +96,10 @@ void PETDB::load()
"offsetX", 0));
currentInfo->setTargetOffsetY(XML::getProperty(petNode,
"offsetY", 1));
+ currentInfo->setSitOffsetX(XML::getProperty(petNode,
+ "sitOffsetX", 0));
+ currentInfo->setSitOffsetY(XML::getProperty(petNode,
+ "sitOffsetY", 1));
SpriteDisplay display;