mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2026-10-02 10:53:44 +00:00
The live server scripts (l_fv_panda_server.lua, l_crab_server.lua, in the client's res/scripts) take a tamed pet out of the groups it was spawned into: the panda leaves "pandas" and "panda<tamer>", the crab "crab<tamer>". The panda spawner counts "pandas" (at most five) and "panda<player>" (one per player), so tamed pandas used to keep counting against both. Entity gets RemoveFromGroup for it. The dig and object pet scripts keep their TODO: their live server scripts are not shipped with the client. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
39 lines
1.4 KiB
C++
39 lines
1.4 KiB
C++
#include "FvPandaServer.h"
|
|
#include "PetComponent.h"
|
|
#include "Character.h"
|
|
#include "ePetTamingNotifyType.h"
|
|
|
|
void FvPandaServer::OnStartup(Entity* self) {
|
|
const auto* petComponent = self->GetComponent<PetComponent>();
|
|
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) {
|
|
self->CancelAllTimers();
|
|
} else if (type == ePetTamingNotifyType::QUIT || type == ePetTamingNotifyType::FAILED) {
|
|
self->Smash();
|
|
} else if (type == ePetTamingNotifyType::SUCCESS) {
|
|
// A tamed panda no longer counts against the spawner's limit or the tamer's one panda (live script)
|
|
self->RemoveFromGroup("pandas");
|
|
self->RemoveFromGroup("panda" + std::to_string(tamer->GetObjectID()));
|
|
|
|
auto* character = tamer->GetCharacter();
|
|
if (character != nullptr) {
|
|
character->SetPlayerFlag(82, true);
|
|
}
|
|
}
|
|
}
|
|
|
|
void FvPandaServer::OnTimerDone(Entity* self, std::string timerName) {
|
|
if (timerName == "killSelf") {
|
|
const auto* petComponent = self->GetComponent<PetComponent>();
|
|
if (petComponent != nullptr && petComponent->GetOwner() == nullptr) {
|
|
self->Smash(self->GetObjectID(), eKillType::SILENT);
|
|
}
|
|
}
|
|
}
|