2021-12-05 17:54:36 +00:00
|
|
|
#include "GfCaptainsCannon.h"
|
|
|
|
#include "GameMessages.h"
|
|
|
|
#include "EntityManager.h"
|
|
|
|
#include "MissionComponent.h"
|
2023-03-20 13:10:52 +00:00
|
|
|
#include "RenderComponent.h"
|
2023-05-02 22:39:21 +00:00
|
|
|
#include "eTerminateType.h"
|
|
|
|
#include "eStateChangeType.h"
|
2021-12-05 17:54:36 +00:00
|
|
|
|
|
|
|
void GfCaptainsCannon::OnUse(Entity* self, Entity* user) {
|
|
|
|
if (self->GetVar<bool>(u"bIsInUse")) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
self->SetVar<LWOOBJID>(u"userID", user->GetObjectID());
|
|
|
|
|
|
|
|
self->SetVar<bool>(u"bIsInUse", true);
|
|
|
|
self->SetNetworkVar<bool>(u"bIsInUse", true);
|
|
|
|
|
2023-01-07 05:59:19 +00:00
|
|
|
GameMessages::SendSetStunned(user->GetObjectID(), eStateChangeType::PUSH, user->GetSystemAddress(),
|
2021-12-05 17:54:36 +00:00
|
|
|
LWOOBJID_EMPTY, true, true, true, true, true, true, true, true
|
|
|
|
);
|
|
|
|
|
|
|
|
auto position = self->GetPosition();
|
|
|
|
auto forward = self->GetRotation().GetForwardVector();
|
|
|
|
|
|
|
|
position.x += forward.x * -3;
|
|
|
|
position.z += forward.z * -3;
|
|
|
|
|
|
|
|
auto rotation = self->GetRotation();
|
|
|
|
|
|
|
|
GameMessages::SendTeleport(user->GetObjectID(), position, rotation, user->GetSystemAddress());
|
|
|
|
|
2023-03-20 13:10:52 +00:00
|
|
|
RenderComponent::PlayAnimation(user, u"cannon-strike-no-equip");
|
2021-12-05 17:54:36 +00:00
|
|
|
|
|
|
|
GameMessages::SendPlayFXEffect(user->GetObjectID(), 6039, u"hook", "hook", LWOOBJID_EMPTY, 1, 1, true);
|
2022-07-28 13:39:57 +00:00
|
|
|
|
2021-12-05 17:54:36 +00:00
|
|
|
self->AddTimer("FireCannon", 1.667f);
|
|
|
|
}
|
|
|
|
|
|
|
|
void GfCaptainsCannon::OnTimerDone(Entity* self, std::string timerName) {
|
|
|
|
const auto playerId = self->GetVar<LWOOBJID>(u"userID");
|
|
|
|
|
|
|
|
auto* player = EntityManager::Instance()->GetEntity(playerId);
|
|
|
|
|
|
|
|
if (player == nullptr) {
|
|
|
|
self->SetVar<bool>(u"bIsInUse", false);
|
|
|
|
self->SetNetworkVar<bool>(u"bIsInUse", false);
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (timerName == "FireCannon") {
|
|
|
|
float cinematicTime = 6.3f;
|
|
|
|
|
|
|
|
GameMessages::SendPlayCinematic(playerId, u"Cannon_Cam", player->GetSystemAddress());
|
|
|
|
|
|
|
|
self->AddTimer("cinematicTimer", cinematicTime);
|
|
|
|
|
|
|
|
const auto sharkObjects = EntityManager::Instance()->GetEntitiesInGroup("SharkCannon");
|
|
|
|
|
|
|
|
for (auto* shark : sharkObjects) {
|
|
|
|
if (shark->GetLOT() != m_SharkItemID) continue;
|
|
|
|
|
2023-03-20 13:10:52 +00:00
|
|
|
RenderComponent::PlayAnimation(shark, u"cannon");
|
2021-12-05 17:54:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
GameMessages::SendPlay2DAmbientSound(player, "{7457d85c-4537-4317-ac9d-2f549219ea87}");
|
|
|
|
} else if (timerName == "cinematicTimer") {
|
2023-01-07 05:59:19 +00:00
|
|
|
GameMessages::SendSetStunned(playerId, eStateChangeType::POP, player->GetSystemAddress(),
|
2021-12-05 17:54:36 +00:00
|
|
|
LWOOBJID_EMPTY, true, true, true, true, true, true, true, true
|
|
|
|
);
|
|
|
|
|
|
|
|
self->SetVar<bool>(u"bIsInUse", false);
|
|
|
|
self->SetNetworkVar<bool>(u"bIsInUse", false);
|
|
|
|
|
|
|
|
GameMessages::SendStopFXEffect(player, true, "hook");
|
|
|
|
|
|
|
|
auto* missionComponent = player->GetComponent<MissionComponent>();
|
|
|
|
|
|
|
|
if (missionComponent != nullptr) {
|
|
|
|
missionComponent->ForceProgress(601, 910, 1);
|
|
|
|
}
|
|
|
|
|
2023-05-02 22:39:21 +00:00
|
|
|
GameMessages::SendTerminateInteraction(playerId, eTerminateType::FROM_INTERACTION, self->GetObjectID());
|
2021-12-05 17:54:36 +00:00
|
|
|
}
|
|
|
|
}
|