2021-12-05 17:54:36 +00:00
|
|
|
#include "GfTikiTorch.h"
|
|
|
|
#include "GameMessages.h"
|
|
|
|
#include "EntityManager.h"
|
2022-07-05 06:00:10 +00:00
|
|
|
#include "MissionComponent.h"
|
2021-12-05 17:54:36 +00:00
|
|
|
#include "RenderComponent.h"
|
2022-07-05 06:00:10 +00:00
|
|
|
#include "eMissionTaskType.h"
|
2023-03-04 07:16:37 +00:00
|
|
|
#include "eReplicaComponentType.h"
|
2023-03-20 13:10:52 +00:00
|
|
|
#include "RenderComponent.h"
|
2023-05-02 22:39:21 +00:00
|
|
|
#include "eTerminateType.h"
|
2021-12-05 17:54:36 +00:00
|
|
|
|
|
|
|
void GfTikiTorch::OnStartup(Entity* self) {
|
|
|
|
LightTorch(self);
|
|
|
|
}
|
|
|
|
|
|
|
|
void GfTikiTorch::OnUse(Entity* self, Entity* killer) {
|
|
|
|
if (self->GetBoolean(u"isInUse")) {
|
|
|
|
self->SetBoolean(u"isInUse", false);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2023-03-20 13:10:52 +00:00
|
|
|
RenderComponent::PlayAnimation(self, u"interact");
|
2021-12-05 17:54:36 +00:00
|
|
|
self->SetI64(u"userID", killer->GetObjectID());
|
|
|
|
|
|
|
|
for (int i = 0; i < m_numspawn; i++) {
|
|
|
|
GameMessages::SendDropClientLoot(killer, self->GetObjectID(), 935, 0, self->GetPosition());
|
|
|
|
}
|
|
|
|
|
|
|
|
self->AddTimer("InteractionCooldown", 4);
|
|
|
|
}
|
|
|
|
|
|
|
|
void GfTikiTorch::OnTimerDone(Entity* self, std::string timerName) {
|
|
|
|
if (timerName == "Relight") {
|
|
|
|
LightTorch(self);
|
|
|
|
} else if (timerName == "InteractionCooldown") {
|
|
|
|
Entity* player = EntityManager::Instance()->GetEntity(self->GetI64(u"userID"));
|
2022-07-28 13:39:57 +00:00
|
|
|
|
2021-12-05 17:54:36 +00:00
|
|
|
if (player != nullptr && player->GetCharacter()) {
|
2023-05-02 22:39:21 +00:00
|
|
|
GameMessages::SendTerminateInteraction(player->GetObjectID(), eTerminateType::FROM_INTERACTION, self->GetObjectID());
|
2021-12-05 17:54:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
self->SetBoolean(u"isInUse", false);
|
|
|
|
|
|
|
|
self->SetI64(u"userID", 0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void GfTikiTorch::LightTorch(Entity* self) {
|
2023-06-07 07:23:50 +00:00
|
|
|
auto renderComponent = self->GetComponent<RenderComponent>();
|
2021-12-05 17:54:36 +00:00
|
|
|
if (renderComponent == nullptr)
|
|
|
|
return;
|
2022-07-28 13:39:57 +00:00
|
|
|
|
2021-12-05 17:54:36 +00:00
|
|
|
self->SetBoolean(u"isInUse", false);
|
|
|
|
|
|
|
|
renderComponent->PlayEffect(611, u"fire", "tikitorch");
|
|
|
|
self->SetBoolean(u"isBurning", true);
|
|
|
|
}
|
|
|
|
|
|
|
|
void GfTikiTorch::OnSkillEventFired(Entity* self, Entity* caster, const std::string& message) {
|
|
|
|
if (self->GetBoolean(u"isBurning") && message == "waterspray") {
|
2023-03-20 13:10:52 +00:00
|
|
|
RenderComponent::PlayAnimation(self, u"water");
|
2022-07-28 13:39:57 +00:00
|
|
|
|
2023-06-07 07:23:50 +00:00
|
|
|
auto renderComponent = self->GetComponent<RenderComponent>();
|
2021-12-05 17:54:36 +00:00
|
|
|
if (renderComponent != nullptr) {
|
|
|
|
renderComponent->StopEffect("tikitorch");
|
|
|
|
renderComponent->PlayEffect(611, u"water", "water");
|
|
|
|
renderComponent->PlayEffect(611, u"steam", "steam");
|
|
|
|
}
|
2022-07-28 13:39:57 +00:00
|
|
|
|
2023-06-07 07:23:50 +00:00
|
|
|
auto casterMissionComponent = caster->GetComponent<MissionComponent>();
|
2021-12-05 17:54:36 +00:00
|
|
|
if (casterMissionComponent != nullptr) {
|
|
|
|
for (const auto missionID : m_missions) {
|
|
|
|
casterMissionComponent->ForceProgressTaskType(missionID, static_cast<uint32_t>(eMissionTaskType::SCRIPT), 1);
|
|
|
|
}
|
|
|
|
}
|
2022-07-28 13:39:57 +00:00
|
|
|
|
2021-12-05 17:54:36 +00:00
|
|
|
self->AddTimer("Relight", 7.0f);
|
|
|
|
self->SetBoolean(u"isBurning", false);
|
|
|
|
}
|
|
|
|
}
|