2021-12-05 17:54:36 +00:00
|
|
|
#include "FvPandaServer.h"
|
|
|
|
#include "PetComponent.h"
|
|
|
|
#include "Character.h"
|
2023-05-02 22:39:21 +00:00
|
|
|
#include "ePetTamingNotifyType.h"
|
2021-12-05 17:54:36 +00:00
|
|
|
|
|
|
|
void FvPandaServer::OnStartup(Entity* self) {
|
2023-06-09 08:27:05 +00:00
|
|
|
const auto* petComponent = self->GetComponent<PetComponent>();
|
2021-12-05 17:54:36 +00:00
|
|
|
if (petComponent != nullptr && petComponent->GetOwner() == nullptr) {
|
|
|
|
self->SetNetworkVar<std::string>(u"pandatamer", std::to_string(self->GetVar<LWOOBJID>(u"tamer")));
|
|
|
|
self->AddTimer("killSelf", 45);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-05-02 22:39:21 +00:00
|
|
|
void FvPandaServer::OnNotifyPetTamingMinigame(Entity* self, Entity* tamer, ePetTamingNotifyType type) {
|
|
|
|
if (type == ePetTamingNotifyType::BEGIN) {
|
2021-12-05 17:54:36 +00:00
|
|
|
self->CancelAllTimers();
|
2023-05-02 22:39:21 +00:00
|
|
|
} else if (type == ePetTamingNotifyType::QUIT || type == ePetTamingNotifyType::FAILED) {
|
2021-12-05 17:54:36 +00:00
|
|
|
self->Smash();
|
2023-05-02 22:39:21 +00:00
|
|
|
} else if (type == ePetTamingNotifyType::SUCCESS) {
|
2021-12-05 17:54:36 +00:00
|
|
|
// TODO: Remove from groups
|
|
|
|
|
|
|
|
auto* character = tamer->GetCharacter();
|
|
|
|
if (character != nullptr) {
|
|
|
|
character->SetPlayerFlag(82, true);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void FvPandaServer::OnTimerDone(Entity* self, std::string timerName) {
|
|
|
|
if (timerName == "killSelf") {
|
2023-06-09 08:27:05 +00:00
|
|
|
const auto* petComponent = self->GetComponent<PetComponent>();
|
2021-12-05 17:54:36 +00:00
|
|
|
if (petComponent != nullptr && petComponent->GetOwner() == nullptr) {
|
2023-05-02 22:39:21 +00:00
|
|
|
self->Smash(self->GetObjectID(), eKillType::SILENT);
|
2021-12-05 17:54:36 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|