DarkflameServer/dScripts/ai/GF/GfCampfire.cpp

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

102 lines
2.8 KiB
C++
Raw Normal View History

#include "GfCampfire.h"
#include "RenderComponent.h"
#include "SkillComponent.h"
#include "MissionComponent.h"
#include "RenderComponent.h"
#include "EntityManager.h"
#include "eReplicaComponentType.h"
void GfCampfire::OnStartup(Entity* self) {
self->SetI32(u"counter", static_cast<int32_t>(0));
self->SetProximityRadius(2.0f, "placeholder");
self->SetBoolean(u"isBurning", true);
2023-06-07 07:23:50 +00:00
auto render = self->GetComponent<RenderComponent>();
if (render == nullptr)
return;
render->PlayEffect(295, u"running", "Burn");
}
void GfCampfire::OnFireEventServerSide(Entity* self, Entity* sender, std::string args, int32_t param1, int32_t param2,
int32_t param3) {
if (args == "physicsReady") {
2023-06-07 07:23:50 +00:00
auto render = self->GetComponent<RenderComponent>();
render->PlayEffect(295, u"running", "Burn");
}
}
void GfCampfire::OnProximityUpdate(Entity* self, Entity* entering, std::string name, std::string status) {
2023-06-07 07:23:50 +00:00
auto skill = self->GetComponent<SkillComponent>();
if (self->GetBoolean(u"isBurning")) {
if (status == "ENTER") {
if (entering->GetCharacter()) {
int32_t counter = self->GetI32(u"counter");
counter = counter + 1;
self->SetI32(u"counter", counter);
if (counter == 1) {
skill->CalculateBehavior(m_skillCastId, 115, entering->GetObjectID());
self->AddTimer("TimeBetweenCast", FIRE_COOLDOWN);
//self->SetVar<LWOOBJID>("target", entering->GetObjectID());
2023-06-07 07:23:50 +00:00
auto missionComponet = entering->GetComponent<MissionComponent>();
if (missionComponet != nullptr) {
missionComponet->ForceProgress(440, 658, 1);
}
}
}
} else {
int32_t counter = self->GetI32(u"counter");
if (counter > 0) {
counter = counter - 1;
self->SetI32(u"counter", counter);
if (counter == 0) {
self->CancelAllTimers();
}
}
}
}
}
void GfCampfire::OnSkillEventFired(Entity* self, Entity* caster, const std::string& message) {
if (message == "waterspray" && self->GetVar<bool>(u"isBurning")) {
2023-06-07 07:23:50 +00:00
auto renderComponent = self->GetComponent<RenderComponent>();
if (renderComponent != nullptr) {
renderComponent->StopEffect("Burn");
renderComponent->PlayEffect(295, u"idle", "Off");
2022-07-28 13:39:57 +00:00
self->SetVar<bool>(u"isBurning", false);
self->AddTimer("FireRestart", 37);
}
}
}
void GfCampfire::OnTimerDone(Entity* self, std::string timerName) {
if (timerName == "TimeBetweenCast") {
/*
self->AddTimer("TimeBetweenCast", FIRE_COOLDOWN);
const auto targetId = self->GetVar<LWOOBJID>("target");
auto* entering = EntityManager::Instance()->GetEntity(targetId);
if (entering == nullptr)
{
2022-07-28 13:39:57 +00:00
}
*/
} else if (timerName == "FireRestart" && !self->GetVar<bool>(u"isBurning")) {
2023-06-07 07:23:50 +00:00
auto renderComponent = self->GetComponent<RenderComponent>();
if (renderComponent != nullptr) {
renderComponent->StopEffect("Off");
renderComponent->PlayEffect(295, u"running", "Burn");
self->SetVar<bool>(u"isBurning", true);
}
}
}