2021-12-05 17:54:36 +00:00
|
|
|
#include "FvFlyingCreviceDragon.h"
|
|
|
|
#include "GameMessages.h"
|
|
|
|
#include "EntityManager.h"
|
|
|
|
#include "SkillComponent.h"
|
|
|
|
#include "GeneralUtils.h"
|
2023-03-20 13:10:52 +00:00
|
|
|
#include "RenderComponent.h"
|
2021-12-05 17:54:36 +00:00
|
|
|
|
2022-07-28 13:39:57 +00:00
|
|
|
void FvFlyingCreviceDragon::OnStartup(Entity* self) {
|
|
|
|
self->AddTimer("waypoint", 5);
|
2021-12-05 17:54:36 +00:00
|
|
|
}
|
|
|
|
|
2022-07-28 13:39:57 +00:00
|
|
|
void FvFlyingCreviceDragon::OnTimerDone(Entity* self, std::string timerName) {
|
|
|
|
if (timerName == "waypoint") {
|
|
|
|
auto point = self->GetVar<int32_t>(u"waypoint");
|
2021-12-05 17:54:36 +00:00
|
|
|
|
2022-07-28 13:39:57 +00:00
|
|
|
if (point >= 20) {
|
|
|
|
point = 0;
|
|
|
|
}
|
2021-12-05 17:54:36 +00:00
|
|
|
|
2022-07-28 13:39:57 +00:00
|
|
|
self->SetVar<int32_t>(u"waypoint", point + 1);
|
2021-12-05 17:54:36 +00:00
|
|
|
|
2022-07-28 13:39:57 +00:00
|
|
|
self->AddTimer("waypoint", 5);
|
2021-12-05 17:54:36 +00:00
|
|
|
|
2022-07-28 13:39:57 +00:00
|
|
|
OnArrived(self);
|
2021-12-05 17:54:36 +00:00
|
|
|
|
2022-07-28 13:39:57 +00:00
|
|
|
return;
|
|
|
|
}
|
2021-12-05 17:54:36 +00:00
|
|
|
|
2022-07-28 13:39:57 +00:00
|
|
|
std::string groupName = "";
|
2021-12-05 17:54:36 +00:00
|
|
|
|
2022-07-28 13:39:57 +00:00
|
|
|
if (timerName == "platform1attack") {
|
|
|
|
groupName = "dragonFireballs1";
|
|
|
|
} else if (timerName == "platform3attack") {
|
|
|
|
groupName = "dragonFireballs3";
|
|
|
|
}
|
2021-12-05 17:54:36 +00:00
|
|
|
|
2023-07-15 20:56:33 +00:00
|
|
|
const auto& group = Game::entityManager->GetEntitiesInGroup(groupName);
|
2021-12-05 17:54:36 +00:00
|
|
|
|
2022-07-28 13:39:57 +00:00
|
|
|
if (group.empty()) {
|
|
|
|
return;
|
|
|
|
}
|
2021-12-05 17:54:36 +00:00
|
|
|
|
2022-07-28 13:39:57 +00:00
|
|
|
auto* skillComponent = group[0]->GetComponent<SkillComponent>();
|
2021-12-05 17:54:36 +00:00
|
|
|
|
2022-07-28 13:39:57 +00:00
|
|
|
if (skillComponent != nullptr) {
|
|
|
|
skillComponent->CalculateBehavior(762, 12506, LWOOBJID_EMPTY, true);
|
|
|
|
}
|
2021-12-05 17:54:36 +00:00
|
|
|
|
2022-07-28 13:39:57 +00:00
|
|
|
auto minionCount = 1;
|
|
|
|
for (size_t i = 1; i < group.size(); i++) {
|
|
|
|
if (minionCount == 4) {
|
|
|
|
return;
|
|
|
|
}
|
2021-12-05 17:54:36 +00:00
|
|
|
|
2022-07-28 13:39:57 +00:00
|
|
|
if (/*GeneralUtils::GenerateRandomNumber<int32_t>(1, 5) > 3*/ true) {
|
|
|
|
skillComponent = group[i]->GetComponent<SkillComponent>();
|
2021-12-05 17:54:36 +00:00
|
|
|
|
2022-07-28 13:39:57 +00:00
|
|
|
if (skillComponent != nullptr) {
|
|
|
|
skillComponent->CalculateBehavior(762, 12506, LWOOBJID_EMPTY);
|
2021-12-05 17:54:36 +00:00
|
|
|
|
2022-07-28 13:39:57 +00:00
|
|
|
++minionCount;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2021-12-05 17:54:36 +00:00
|
|
|
}
|
|
|
|
|
2022-07-28 13:39:57 +00:00
|
|
|
void FvFlyingCreviceDragon::OnArrived(Entity* self) {
|
|
|
|
auto point = self->GetVar<int32_t>(u"waypoint");
|
|
|
|
|
|
|
|
if (point == 4) {
|
2023-03-20 13:10:52 +00:00
|
|
|
RenderComponent::PlayAnimation(self, u"attack1", 2.0f);
|
2022-07-28 13:39:57 +00:00
|
|
|
self->AddTimer("platform1attack", 1.75f);
|
|
|
|
} else if (point == 12) {
|
2023-03-20 13:10:52 +00:00
|
|
|
RenderComponent::PlayAnimation(self, u"attack2", 2.0f);
|
2022-07-28 13:39:57 +00:00
|
|
|
|
2023-07-15 20:56:33 +00:00
|
|
|
const auto& group2 = Game::entityManager->GetEntitiesInGroup("dragonFireballs2");
|
2022-07-28 13:39:57 +00:00
|
|
|
|
|
|
|
if (group2.empty()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
auto* skillComponent = group2[0]->GetComponent<SkillComponent>();
|
|
|
|
|
|
|
|
if (skillComponent != nullptr) {
|
|
|
|
skillComponent->CalculateBehavior(762, 12506, LWOOBJID_EMPTY);
|
|
|
|
}
|
|
|
|
|
|
|
|
auto minionCount = 1;
|
|
|
|
for (size_t i = 1; i < group2.size(); i++) {
|
|
|
|
if (minionCount == 4) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (GeneralUtils::GenerateRandomNumber<int32_t>(1, 5) > 3) {
|
|
|
|
skillComponent = group2[i]->GetComponent<SkillComponent>();
|
|
|
|
|
|
|
|
if (skillComponent != nullptr) {
|
|
|
|
skillComponent->CalculateBehavior(762, 12506, LWOOBJID_EMPTY, true);
|
|
|
|
|
|
|
|
++minionCount;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else if (point == 16) {
|
2023-03-20 13:10:52 +00:00
|
|
|
RenderComponent::PlayAnimation(self, u"attack3", 2.0f);
|
2022-07-28 13:39:57 +00:00
|
|
|
self->AddTimer("platform3attack", 0.5f);
|
|
|
|
}
|
2021-12-05 17:54:36 +00:00
|
|
|
}
|