diff options
Diffstat (limited to 'src/actions')
-rw-r--r-- | src/actions/pets.cpp | 47 | ||||
-rw-r--r-- | src/actions/pets.h | 4 |
2 files changed, 51 insertions, 0 deletions
diff --git a/src/actions/pets.cpp b/src/actions/pets.cpp index 30cfc9613..e30e7f529 100644 --- a/src/actions/pets.cpp +++ b/src/actions/pets.cpp @@ -62,6 +62,17 @@ namespace Actions { +static const Being *getPet() +{ + if (!localPlayer) + return nullptr; + + const std::vector<Being*> &pets = localPlayer->getPets(); + if (pets.empty()) + return nullptr; + return *pets.begin(); +} + impHandler(commandEmotePet) { // need use actual pet id @@ -130,4 +141,40 @@ impHandler(catchPet) return true; } +impHandler0(petMoveUp) +{ + const Being *const pet = getPet(); + if (!pet) + return false; + petHandler->move(pet->getId(), pet->getTileX(), pet->getTileY() - 1); + return true; +} + +impHandler0(petMoveDown) +{ + const Being *const pet = getPet(); + if (!pet) + return false; + petHandler->move(pet->getId(), pet->getTileX(), pet->getTileY() + 1); + return true; +} + +impHandler0(petMoveLeft) +{ + const Being *const pet = getPet(); + if (!pet) + return false; + petHandler->move(pet->getId(), pet->getTileX() - 1, pet->getTileY()); + return true; +} + +impHandler0(petMoveRight) +{ + const Being *const pet = getPet(); + if (!pet) + return false; + petHandler->move(pet->getId(), pet->getTileX() + 1, pet->getTileY()); + return true; +} + } // namespace Actions diff --git a/src/actions/pets.h b/src/actions/pets.h index e0521b546..37bd85713 100644 --- a/src/actions/pets.h +++ b/src/actions/pets.h @@ -32,6 +32,10 @@ namespace Actions decHandler(setPetName); decHandler(petEmote); decHandler(catchPet); + decHandler(petMoveUp); + decHandler(petMoveDown); + decHandler(petMoveLeft); + decHandler(petMoveRight); } // namespace Actions #undef decHandler |