mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2024-11-25 23:17:28 +00:00
a0d51e21ca
* allow usage of NiPoint3 and NiQuaternion in constexpr context * removed .cpp files entirely * moving circular dependency circumvention stuff to an .inl file * real world usage!!!!! * reverting weird branch cross-pollination * removing more weird branch cross-pollination * remove comment * added inverse header guard to inl file * Update NiPoint3.inl * trying different constructor syntax * reorganize into .inl files for readability * uncomment include * moved non-constexpr definitions to cpp file * moved static definitions back to inl files * testing fix * moved constants into seperate namespace * Undo change in build-and-test.yml * nodiscard
46 lines
1.7 KiB
C++
46 lines
1.7 KiB
C++
#include "PetFromDigServer.h"
|
|
#include "PetComponent.h"
|
|
#include "ePetTamingNotifyType.h"
|
|
|
|
void PetFromDigServer::OnStartup(Entity* self) {
|
|
auto* petComponent = self->GetComponent<PetComponent>();
|
|
if (petComponent == nullptr || petComponent->GetOwner() != nullptr)
|
|
return;
|
|
|
|
// Triggers the local dig pet script for taming etc.
|
|
auto tamer = self->GetVar<LWOOBJID>(u"tamer");
|
|
|
|
// Client compares this with player:GetID() which is a string, so we'll have to give it a string
|
|
self->SetNetworkVar(u"pettamer", std::to_string(tamer));
|
|
|
|
// Kill if the player decides that the dig pet is not worthy
|
|
self->AddTimer("killself", 45.0f);
|
|
}
|
|
|
|
void PetFromDigServer::OnTimerDone(Entity* self, std::string timerName) {
|
|
if (timerName == "killself") {
|
|
|
|
// Don't accidentally kill a pet that is already owned
|
|
auto* petComponent = self->GetComponent<PetComponent>();
|
|
if (petComponent == nullptr || petComponent->GetOwner() != nullptr)
|
|
return;
|
|
|
|
self->Smash(self->GetObjectID(), eKillType::SILENT);
|
|
}
|
|
}
|
|
|
|
void PetFromDigServer::OnNotifyPetTamingMinigame(Entity* self, Entity* tamer, ePetTamingNotifyType type) {
|
|
if (type == ePetTamingNotifyType::BEGIN) {
|
|
self->CancelTimer("killself");
|
|
} else if (type == ePetTamingNotifyType::QUIT || type == ePetTamingNotifyType::FAILED) {
|
|
self->Smash(self->GetObjectID(), eKillType::SILENT);
|
|
} else if (type == ePetTamingNotifyType::SUCCESS) {
|
|
auto* petComponent = self->GetComponent<PetComponent>();
|
|
if (petComponent == nullptr)
|
|
return;
|
|
// TODO: Remove custom group?
|
|
// Command the pet to the player as it may otherwise go to its spawn point which is non existant
|
|
// petComponent->Command(NiPoint3Constant::ZERO, LWOOBJID_EMPTY, 6, 202, true);
|
|
}
|
|
}
|