2021-12-05 17:54:36 +00:00
|
|
|
#include "StinkyFishTarget.h"
|
|
|
|
#include "EntityManager.h"
|
2023-01-07 05:17:05 +00:00
|
|
|
#include "EntityInfo.h"
|
2023-02-28 23:30:28 +00:00
|
|
|
#include "Entity.h"
|
2021-12-05 17:54:36 +00:00
|
|
|
|
|
|
|
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{};
|
2023-02-28 23:30:28 +00:00
|
|
|
entityInfo.lot = SHARK_LOT;
|
2021-12-05 17:54:36 +00:00
|
|
|
entityInfo.pos = self->GetPosition();
|
|
|
|
entityInfo.rot = self->GetRotation();
|
|
|
|
entityInfo.spawnerID = self->GetObjectID();
|
|
|
|
entityInfo.settings = {
|
|
|
|
new LDFData<bool>(u"no_timed_spawn", true)
|
|
|
|
};
|
|
|
|
|
2023-07-15 20:56:33 +00:00
|
|
|
auto* fish = Game::entityManager->CreateEntity(entityInfo);
|
|
|
|
Game::entityManager->ConstructEntity(fish);
|
2021-12-05 17:54:36 +00:00
|
|
|
|
|
|
|
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");
|
2023-07-15 20:56:33 +00:00
|
|
|
auto* fish = Game::entityManager->GetEntity(self->GetVar<LWOOBJID>(u"fish"));
|
2021-12-05 17:54:36 +00:00
|
|
|
|
2023-02-28 23:30:28 +00:00
|
|
|
if (fish) {
|
2021-12-05 17:54:36 +00:00
|
|
|
fish->Smash(playerID);
|
|
|
|
self->Smash(playerID);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|