diff options
Diffstat (limited to 'src/being')
-rw-r--r-- | src/being/being.cpp | 39 | ||||
-rw-r--r-- | src/being/being.h | 2 |
2 files changed, 39 insertions, 2 deletions
diff --git a/src/being/being.cpp b/src/being/being.cpp index 90912e8a7..b7d6019ec 100644 --- a/src/being/being.cpp +++ b/src/being/being.cpp @@ -1644,6 +1644,7 @@ void Being::petLogic() if (divX >= warpDist || divY >= warpDist) { setAction(Being::STAND, 0); + fixPetSpawnPos(dstX, dstY); setTileCoords(dstX, dstY); Net::getPetHandler()->spawn(mOwner, dstX, dstY); } @@ -3134,11 +3135,14 @@ void Being::addPet(const int id) id, ActorSprite::PET, 0); if (being) { - being->setTileCoords(mX, mY); being->setOwner(this); mPetId = id; mPet = being; - Net::getPetHandler()->spawn(this, mX, mY); + int dstX = mX; + int dstY = mY; + being->fixPetSpawnPos(dstX, dstY); + being->setTileCoords(dstX, dstY); + Net::getPetHandler()->spawn(this, dstX, dstY); } } @@ -3175,6 +3179,37 @@ void Being::updatePets() } } +void Being::fixPetSpawnPos(int &dstX, int &dstY) const +{ + if (!mInfo || !mOwner) + return; + + const int offsetX1 = mInfo->getTargetOffsetX(); + const int offsetY1 = mInfo->getTargetOffsetY(); + int offsetX = offsetX1; + int offsetY = offsetY1; + switch (mOwner->getDirection()) + { + case LEFT: + offsetX = offsetY1; + offsetY = -offsetX1; + break; + case RIGHT: + offsetX = offsetY1; + offsetY = offsetX1; + break; + case UP: + offsetY = -offsetY; + break; + default: + case DOWN: + break; + } + logger->log("fix offset: %d,%d", offsetX, offsetY); + dstX += offsetX; + dstY += offsetY; +} + void Being::playSfx(const SoundInfo &sound, Being *const being, const bool main, const int x, const int y) const { diff --git a/src/being/being.h b/src/being/being.h index 6722e5d4c..e8bc7da37 100644 --- a/src/being/being.h +++ b/src/being/being.h @@ -881,6 +881,8 @@ class Being : public ActorSprite, public ConfigListener void updatePets(); + void fixPetSpawnPos(int &dstX, int &dstY) const; + Being *getPet() { return mPet; } |