diff options
-rw-r--r-- | src/actions/pets.cpp | 10 | ||||
-rw-r--r-- | src/actions/pets.h | 2 | ||||
-rw-r--r-- | src/gui/windows/chatwindow.cpp | 18 | ||||
-rw-r--r-- | src/gui/windows/chatwindow.h | 4 | ||||
-rw-r--r-- | src/input/inputaction.h | 2 | ||||
-rw-r--r-- | src/input/inputactionmap.h | 18 | ||||
-rw-r--r-- | src/net/eathena/pethandler.cpp | 4 | ||||
-rw-r--r-- | src/net/eathena/pethandler.h | 2 | ||||
-rw-r--r-- | src/net/pethandler.h | 2 | ||||
-rw-r--r-- | src/net/tmwa/pethandler.cpp | 6 | ||||
-rw-r--r-- | src/net/tmwa/pethandler.h | 2 |
11 files changed, 70 insertions, 0 deletions
diff --git a/src/actions/pets.cpp b/src/actions/pets.cpp index 64ac81e83..e211ff0ac 100644 --- a/src/actions/pets.cpp +++ b/src/actions/pets.cpp @@ -201,4 +201,14 @@ impHandler0(petDirectRight) return true; } +impHandler0(petAiStart) +{ + petHandler->startAi(true); +} + +impHandler0(petAiStop) +{ + petHandler->startAi(false); +} + } // namespace Actions diff --git a/src/actions/pets.h b/src/actions/pets.h index 4aed1d94c..25066df38 100644 --- a/src/actions/pets.h +++ b/src/actions/pets.h @@ -40,6 +40,8 @@ namespace Actions decHandler(petDirectDown); decHandler(petDirectLeft); decHandler(petDirectRight); + decHandler(petAiStart); + decHandler(petAiStop); } // namespace Actions #undef decHandler diff --git a/src/gui/windows/chatwindow.cpp b/src/gui/windows/chatwindow.cpp index 553deea70..a707ac8c4 100644 --- a/src/gui/windows/chatwindow.cpp +++ b/src/gui/windows/chatwindow.cpp @@ -1529,6 +1529,12 @@ bool ChatWindow::resortChatLog(std::string line, localPetDirection(nick, static_cast<BeingDirection::Type>( atoi(line.c_str()))); } + else if (line.find(": \302\202\302a") != std::string::npos) + { + const std::string nick = line.substr(0, idx2 - 1); + line = line.substr(idx2 + 6); + localPetAi(nick, atoi(line.c_str()) ? true : false); + } // ignore other special message formats. return false; } @@ -1690,6 +1696,18 @@ void ChatWindow::localPetEmote(const std::string &nick, const uint8_t emoteId) pet->setEmote(emoteId, 0); } +void ChatWindow::localPetAi(const std::string &nick, const bool start) +{ + Being *const pet = getPetForNick(nick); + if (pet) + { + if (start) + pet->enablePetAi(); + else + pet->disablePetAi(); + } +} + void ChatWindow::localPetMove(const std::string &nick, const int x, const int y) { diff --git a/src/gui/windows/chatwindow.h b/src/gui/windows/chatwindow.h index bbc188c3a..9455557dd 100644 --- a/src/gui/windows/chatwindow.h +++ b/src/gui/windows/chatwindow.h @@ -304,6 +304,10 @@ class ChatWindow final : public Window, static void localPetDirection(const std::string &nick, BeingDirection::Type dir); + + static void localPetAi(const std::string &nick, + const bool start); + void postConnection(); #ifdef USE_PROFILER diff --git a/src/input/inputaction.h b/src/input/inputaction.h index 67bf95161..59134de0f 100644 --- a/src/input/inputaction.h +++ b/src/input/inputaction.h @@ -524,6 +524,8 @@ namespace InputAction PET_DIRECT_DOWN, PET_DIRECT_LEFT, PET_DIRECT_RIGHT, + PET_AI_START, + PET_AI_STOP, TOTAL }; } // namespace InputAction diff --git a/src/input/inputactionmap.h b/src/input/inputactionmap.h index c5d9d9d76..8c09001a2 100644 --- a/src/input/inputactionmap.h +++ b/src/input/inputactionmap.h @@ -4460,6 +4460,24 @@ static const InputActionData inputActionData[InputAction::TOTAL] = { InputCondition::INGAME, "petdirectright|directrightpet", false}, + {"keyPetAiStart", + InputType::UNKNOWN, InputAction::NO_VALUE, + InputType::UNKNOWN, InputAction::NO_VALUE, + Input::GRP_DEFAULT, + &Actions::petAiStart, + InputAction::NO_VALUE, 50, + InputCondition::INGAME, + "petaistart|startpetai", + false}, + {"keyPetAiStop", + InputType::UNKNOWN, InputAction::NO_VALUE, + InputType::UNKNOWN, InputAction::NO_VALUE, + Input::GRP_DEFAULT, + &Actions::petAiStop, + InputAction::NO_VALUE, 50, + InputCondition::INGAME, + "petaistop|stoppetai", + false}, }; #endif // INPUT_INPUTACTIONMAP_H diff --git a/src/net/eathena/pethandler.cpp b/src/net/eathena/pethandler.cpp index b18cc83d0..c2e4d2b32 100644 --- a/src/net/eathena/pethandler.cpp +++ b/src/net/eathena/pethandler.cpp @@ -323,4 +323,8 @@ void PetHandler::setDirection(const BeingDirection::Type type A_UNUSED) const { } +void PetHandler::startAi(const bool start A_UNUSED) const +{ +} + } // namespace EAthena diff --git a/src/net/eathena/pethandler.h b/src/net/eathena/pethandler.h index b397d98d4..687884251 100644 --- a/src/net/eathena/pethandler.h +++ b/src/net/eathena/pethandler.h @@ -68,6 +68,8 @@ class PetHandler final : public MessageHandler, public Net::PetHandler void setDirection(const BeingDirection::Type type) const override final; + void startAi(const bool start) const override final; + protected: static void processPetRoulette(Net::MessageIn &msg); diff --git a/src/net/pethandler.h b/src/net/pethandler.h index 20e4b945e..50a844df6 100644 --- a/src/net/pethandler.h +++ b/src/net/pethandler.h @@ -58,6 +58,8 @@ class PetHandler notfinal virtual void unequip() const = 0; virtual void setDirection(const BeingDirection::Type type) const = 0; + + virtual void startAi(const bool start) const = 0; }; } // namespace Net diff --git a/src/net/tmwa/pethandler.cpp b/src/net/tmwa/pethandler.cpp index 787b288b5..33bd2cb3c 100644 --- a/src/net/tmwa/pethandler.cpp +++ b/src/net/tmwa/pethandler.cpp @@ -113,4 +113,10 @@ void PetHandler::setDirection(const BeingDirection::Type type) const static_cast<int>(type), tick_time), GENERAL_CHANNEL); } +void PetHandler::startAi(const bool start) const +{ + chatHandler->talk(strprintf("\302\202\302a%dg%d", + start ? 1 : 0, tick_time), GENERAL_CHANNEL); +} + } // namespace TmwAthena diff --git a/src/net/tmwa/pethandler.h b/src/net/tmwa/pethandler.h index 49f32e84d..7b7f40cd0 100644 --- a/src/net/tmwa/pethandler.h +++ b/src/net/tmwa/pethandler.h @@ -66,6 +66,8 @@ class PetHandler final : public MessageHandler, public Net::PetHandler void setDirection(const BeingDirection::Type type) const override final; + void startAi(const bool start) const override final; + protected: int mRandCounter; }; |