2022-08-06 03:01:59 +00:00
|
|
|
#include "AgJetEffectServer.h"
|
2021-12-05 17:54:36 +00:00
|
|
|
#include "GameMessages.h"
|
|
|
|
#include "EntityManager.h"
|
|
|
|
#include "SkillComponent.h"
|
2023-03-04 07:16:37 +00:00
|
|
|
#include "eReplicaComponentType.h"
|
2021-12-05 17:54:36 +00:00
|
|
|
|
2022-07-28 13:39:57 +00:00
|
|
|
void AgJetEffectServer::OnUse(Entity* self, Entity* user) {
|
2023-05-02 10:27:16 +00:00
|
|
|
if (inUse || self->GetLOT() != 6859) return;
|
2021-12-05 17:54:36 +00:00
|
|
|
GameMessages::SendNotifyClientObject(
|
2023-04-18 17:48:03 +00:00
|
|
|
self->GetObjectID(), u"toggleInUse", 1, 0, LWOOBJID_EMPTY, "", UNASSIGNED_SYSTEM_ADDRESS
|
2021-12-05 17:54:36 +00:00
|
|
|
);
|
|
|
|
inUse = true;
|
|
|
|
|
|
|
|
auto entities = EntityManager::Instance()->GetEntitiesInGroup("Jet_FX");
|
2023-04-18 17:48:03 +00:00
|
|
|
if (entities.empty()) return;
|
|
|
|
GameMessages::SendPlayFXEffect(entities.at(0), 641, u"create", "radarDish", LWOOBJID_EMPTY, 1, 1, true);
|
|
|
|
self->AddTimer("radarDish", 2.0f);
|
|
|
|
self->AddTimer("PlayEffect", 2.5f);
|
|
|
|
self->AddTimer("CineDone", 7.5f + 5.0f); // 7.5f is time the cinematic takes to play
|
2021-12-05 17:54:36 +00:00
|
|
|
}
|
|
|
|
|
2022-07-28 13:39:57 +00:00
|
|
|
void AgJetEffectServer::OnRebuildComplete(Entity* self, Entity* target) {
|
2023-04-18 17:48:03 +00:00
|
|
|
if (self->GetLOT() != 6209) return;
|
2021-12-05 17:54:36 +00:00
|
|
|
auto entities = EntityManager::Instance()->GetEntitiesInGroup("Jet_FX");
|
2023-04-18 17:48:03 +00:00
|
|
|
if (entities.empty()) return;
|
|
|
|
GameMessages::SendPlayAnimation(entities.at(0), u"jetFX");
|
2021-12-05 17:54:36 +00:00
|
|
|
|
2023-04-18 17:48:03 +00:00
|
|
|
// So we can give kill credit to person who build this
|
2021-12-05 17:54:36 +00:00
|
|
|
builder = target->GetObjectID();
|
2022-07-25 02:26:51 +00:00
|
|
|
|
2023-04-18 17:48:03 +00:00
|
|
|
auto groups = self->GetGroups();
|
|
|
|
if (!groups.empty() && groups.at(0) == "Base_Radar") {
|
|
|
|
self->AddTimer("PlayEffect", 2.5f);
|
|
|
|
self->AddTimer("CineDone", 7.5f + 5.0f); // 7.5f is time the cinematic takes to play
|
2021-12-05 17:54:36 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-07-28 13:39:57 +00:00
|
|
|
void AgJetEffectServer::OnTimerDone(Entity* self, std::string timerName) {
|
|
|
|
if (timerName == "radarDish") {
|
2021-12-05 17:54:36 +00:00
|
|
|
GameMessages::SendStopFXEffect(self, true, "radarDish");
|
2023-04-18 17:48:03 +00:00
|
|
|
} else if (timerName == "PlayEffect") {
|
2021-12-05 17:54:36 +00:00
|
|
|
auto entities = EntityManager::Instance()->GetEntitiesInGroup("mortarMain");
|
2023-04-18 17:48:03 +00:00
|
|
|
if (entities.empty()) return;
|
2021-12-05 17:54:36 +00:00
|
|
|
|
2023-04-18 17:48:03 +00:00
|
|
|
const auto selected = GeneralUtils::GenerateRandomNumber<int>(0, entities.size() - 1);
|
|
|
|
auto* mortar = entities.at(selected);
|
2021-12-05 17:54:36 +00:00
|
|
|
|
2023-04-18 17:48:03 +00:00
|
|
|
// so we give proper credit to the builder for the kills from this skill
|
2021-12-05 17:54:36 +00:00
|
|
|
mortar->SetOwnerOverride(builder);
|
|
|
|
|
2023-04-18 17:48:03 +00:00
|
|
|
auto* skillComponent = mortar->GetComponent<SkillComponent>();
|
|
|
|
if (skillComponent) skillComponent->CastSkill(318);
|
|
|
|
} else if (timerName == "CineDone") {
|
2021-12-05 17:54:36 +00:00
|
|
|
GameMessages::SendNotifyClientObject(
|
2023-04-18 17:48:03 +00:00
|
|
|
self->GetObjectID(), u"toggleInUse", -1, 0, LWOOBJID_EMPTY, "", UNASSIGNED_SYSTEM_ADDRESS
|
2021-12-05 17:54:36 +00:00
|
|
|
);
|
|
|
|
inUse = false;
|
|
|
|
}
|
|
|
|
}
|