DarkflameServer/dScripts/ai/FV/FvPandaServer.cpp

37 lines
1.2 KiB
C++
Raw Normal View History

#include "FvPandaServer.h"
#include "PetComponent.h"
#include "Character.h"
#include "ePetTamingNotifyType.h"
2022-07-28 13:39:57 +00:00
void FvPandaServer::OnStartup(Entity* self) {
const auto* petComponent = self->GetComponent<PetComponent>();
2022-07-28 13:39:57 +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);
}
}
void FvPandaServer::OnNotifyPetTamingMinigame(Entity* self, Entity* tamer, ePetTamingNotifyType type) {
if (type == ePetTamingNotifyType::BEGIN) {
2022-07-28 13:39:57 +00:00
self->CancelAllTimers();
} else if (type == ePetTamingNotifyType::QUIT || type == ePetTamingNotifyType::FAILED) {
2022-07-28 13:39:57 +00:00
self->Smash();
} else if (type == ePetTamingNotifyType::SUCCESS) {
2022-07-28 13:39:57 +00:00
// TODO: Remove from groups
2022-07-28 13:39:57 +00:00
auto* character = tamer->GetCharacter();
if (character != nullptr) {
character->SetPlayerFlag(82, true);
}
}
}
2022-07-28 13:39:57 +00:00
void FvPandaServer::OnTimerDone(Entity* self, std::string timerName) {
if (timerName == "killSelf") {
const auto* petComponent = self->GetComponent<PetComponent>();
2022-07-28 13:39:57 +00:00
if (petComponent != nullptr && petComponent->GetOwner() == nullptr) {
self->Smash(self->GetObjectID(), eKillType::SILENT);
2022-07-28 13:39:57 +00:00
}
}
}