2021-12-05 17:54:36 +00:00
|
|
|
#include "RainOfArrows.h"
|
|
|
|
#include "EntityManager.h"
|
|
|
|
#include "SkillComponent.h"
|
2023-01-07 05:17:05 +00:00
|
|
|
#include "EntityInfo.h"
|
2021-12-05 17:54:36 +00:00
|
|
|
#include "GameMessages.h"
|
|
|
|
|
|
|
|
void RainOfArrows::OnStartup(Entity* self) {
|
2022-07-28 13:39:57 +00:00
|
|
|
|
2021-12-05 17:54:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void RainOfArrows::OnRebuildComplete(Entity* self, Entity* target) {
|
|
|
|
auto myPos = self->GetPosition();
|
|
|
|
auto myRot = self->GetRotation();
|
2022-07-28 13:39:57 +00:00
|
|
|
|
2021-12-05 17:54:36 +00:00
|
|
|
EntityInfo info;
|
|
|
|
info.lot = m_ArrowFXObject;
|
|
|
|
info.pos = myPos;
|
|
|
|
info.rot = myRot;
|
|
|
|
info.spawnerID = self->GetObjectID();
|
|
|
|
|
|
|
|
auto* entity = EntityManager::Instance()->CreateEntity(info);
|
|
|
|
|
|
|
|
EntityManager::Instance()->ConstructEntity(entity);
|
|
|
|
|
|
|
|
self->SetVar<LWOOBJID>(u"ChildFX", entity->GetObjectID());
|
|
|
|
self->SetVar<LWOOBJID>(u"playerID", target->GetObjectID());
|
|
|
|
|
|
|
|
self->AddTimer("ArrowsIncoming", m_ArrowDelay);
|
|
|
|
self->AddTimer("PlayArrowSound", m_ArrowDelay - 4);
|
|
|
|
}
|
|
|
|
|
|
|
|
void RainOfArrows::OnTimerDone(Entity* self, std::string timerName) {
|
|
|
|
auto* child = EntityManager::Instance()->GetEntity(
|
|
|
|
self->GetVar<LWOOBJID>(u"ChildFX")
|
|
|
|
);
|
2022-07-28 13:39:57 +00:00
|
|
|
|
2021-12-05 17:54:36 +00:00
|
|
|
auto* player = EntityManager::Instance()->GetEntity(
|
|
|
|
self->GetVar<LWOOBJID>(u"playerID")
|
|
|
|
);
|
2022-07-28 13:39:57 +00:00
|
|
|
|
2021-12-05 17:54:36 +00:00
|
|
|
if (timerName == "ArrowsIncoming") {
|
|
|
|
if (child == nullptr) {
|
|
|
|
return;
|
|
|
|
}
|
2022-07-28 13:39:57 +00:00
|
|
|
|
2023-06-07 07:23:50 +00:00
|
|
|
auto skillComponent = child->GetComponent<SkillComponent>();
|
2022-07-28 13:39:57 +00:00
|
|
|
|
2021-12-05 17:54:36 +00:00
|
|
|
if (skillComponent == nullptr) {
|
|
|
|
return;
|
|
|
|
}
|
2022-07-28 13:39:57 +00:00
|
|
|
|
2021-12-05 17:54:36 +00:00
|
|
|
skillComponent->CalculateBehavior(
|
|
|
|
m_ArrowSkill,
|
|
|
|
m_ArrowBehavior,
|
|
|
|
LWOOBJID_EMPTY,
|
|
|
|
true,
|
|
|
|
false,
|
|
|
|
player != nullptr ? player->GetObjectID() : LWOOBJID_EMPTY
|
|
|
|
);
|
2022-07-28 13:39:57 +00:00
|
|
|
|
2021-12-05 17:54:36 +00:00
|
|
|
self->AddTimer("FireSkill", 0.7f);
|
|
|
|
} else if (timerName == "PlayArrowSound") {
|
|
|
|
GameMessages::SendPlayNDAudioEmitter(self, UNASSIGNED_SYSTEM_ADDRESS, m_ArrowsGUID);
|
|
|
|
} else if (timerName == "FireSkill") {
|
|
|
|
if (child != nullptr) {
|
|
|
|
child->Smash();
|
|
|
|
}
|
2022-07-28 13:39:57 +00:00
|
|
|
|
2021-12-05 17:54:36 +00:00
|
|
|
self->Smash(player != nullptr ? player->GetObjectID() : LWOOBJID_EMPTY);
|
|
|
|
}
|
|
|
|
}
|