Files
DarkflameServer/dScripts/02_server/Objects/StinkyFishTarget.cpp
David Markowitz 0101933f5c chore: cleanup pointer management for LDF data (#1995)
* change network settings from vector to LwoNameValue

* move settings on Entity to managed memory

* Migrate more members

* chore: remove pointer leakage from raw ldf pointers

* feedback

* fix ci
2026-06-14 20:54:52 -07:00

44 lines
1.2 KiB
C++

#include "StinkyFishTarget.h"
#include "EntityManager.h"
#include "EntityInfo.h"
#include "Entity.h"
void StinkyFishTarget::OnStartup(Entity* self) {
auto position = self->GetPosition();
position.SetY(position.GetY() - 0.5f);
self->SetPosition(position);
}
void StinkyFishTarget::OnSkillEventFired(Entity* self, Entity* caster, const std::string& message) {
if (message != "stinkfish" || self->GetVar<bool>(u"used"))
return;
self->SetVar<bool>(u"used", true);
self->SetVar<LWOOBJID>(u"player", caster->GetObjectID());
EntityInfo entityInfo{};
entityInfo.lot = SHARK_LOT;
entityInfo.pos = self->GetPosition();
entityInfo.rot = self->GetRotation();
entityInfo.spawnerID = self->GetObjectID();
entityInfo.settings.Insert(u"no_timed_spawn", true);
auto* fish = Game::entityManager->CreateEntity(entityInfo);
Game::entityManager->ConstructEntity(fish);
self->SetVar<LWOOBJID>(u"fish", fish->GetObjectID());
self->AddTimer("smash", 5.0f);
}
void StinkyFishTarget::OnTimerDone(Entity* self, std::string timerName) {
if (timerName == "smash") {
const auto playerID = self->GetVar<LWOOBJID>(u"player");
auto* fish = Game::entityManager->GetEntity(self->GetVar<LWOOBJID>(u"fish"));
if (fish) {
fish->Smash(playerID);
self->Smash(playerID);
}
}
}