DarkflameServer/dScripts/RaceMaelstromGeiser.cpp

86 lines
2.2 KiB
C++
Raw Normal View History

#include "RaceMaelstromGeiser.h"
#include "GameMessages.h"
#include "PossessableComponent.h"
#include "PossessorComponent.h"
#include "EntityManager.h"
#include "RacingControlComponent.h"
#include "dZoneManager.h"
2022-07-28 13:39:57 +00:00
void RaceMaelstromGeiser::OnStartup(Entity* self) {
self->SetVar(u"AmFiring", false);
2022-07-28 13:39:57 +00:00
self->AddTimer("downTime", self->GetVar<int32_t>(u"startTime"));
self->SetProximityRadius(15, "deathZone");
}
2022-07-28 13:39:57 +00:00
void RaceMaelstromGeiser::OnProximityUpdate(Entity* self, Entity* entering, std::string name, std::string status) {
if (!entering->IsPlayer() || name != "deathZone" || status != "ENTER") {
return;
}
if (!self->GetVar<bool>(u"AmFiring")) {
return;
}
2022-07-28 13:39:57 +00:00
auto* possessableComponent = entering->GetComponent<PossessableComponent>();
2022-07-28 13:39:57 +00:00
Entity* vehicle;
Entity* player;
2022-07-28 13:39:57 +00:00
if (possessableComponent != nullptr) {
player = EntityManager::Instance()->GetEntity(possessableComponent->GetPossessor());
2022-07-28 13:39:57 +00:00
if (player == nullptr) {
return;
}
2022-07-28 13:39:57 +00:00
vehicle = entering;
} else if (entering->IsPlayer()) {
auto* possessorComponent = entering->GetComponent<PossessorComponent>();
2022-07-28 13:39:57 +00:00
if (possessorComponent == nullptr) {
return;
}
2022-07-28 13:39:57 +00:00
vehicle = EntityManager::Instance()->GetEntity(possessorComponent->GetPossessable());
2022-07-28 13:39:57 +00:00
if (vehicle == nullptr) {
return;
}
2022-07-28 13:39:57 +00:00
player = entering;
} else {
return;
}
2022-07-28 13:39:57 +00:00
GameMessages::SendDie(vehicle, self->GetObjectID(), LWOOBJID_EMPTY, true, VIOLENT, u"", 0, 0, 0, true, false, 0);
2022-07-28 13:39:57 +00:00
auto* zoneController = dZoneManager::Instance()->GetZoneControlObject();
2022-07-28 13:39:57 +00:00
auto* racingControlComponent = zoneController->GetComponent<RacingControlComponent>();
2022-07-28 13:39:57 +00:00
if (racingControlComponent != nullptr) {
racingControlComponent->OnRequestDie(player);
}
}
2022-07-28 13:39:57 +00:00
void RaceMaelstromGeiser::OnTimerDone(Entity* self, std::string timerName) {
if (timerName == "downTime") {
GameMessages::SendPlayFXEffect(self->GetObjectID(), 4048, u"rebuild_medium", "geiser", LWOOBJID_EMPTY, 1, 1, true);
2022-07-28 13:39:57 +00:00
self->AddTimer("buildUpTime", 1);
} else if (timerName == "buildUpTime") {
self->SetVar(u"AmFiring", true);
2022-07-28 13:39:57 +00:00
self->AddTimer("killTime", 1.5f);
} else if (timerName == "killTime") {
GameMessages::SendStopFXEffect(self, true, "geiser");
2022-07-28 13:39:57 +00:00
self->SetVar(u"AmFiring", false);
2022-07-28 13:39:57 +00:00
self->AddTimer("downTime", 3.0);
}
}