DarkflameServer/dScripts/02_server/Map/njhub/RainOfArrows.cpp
David Markowitz fc75d6048f
dGame Precompiled header improvements (#876)
* moving branch

* Add deleteinven slash command

* Change name of BRICKS_IN_BBB

* Use string_view instead of strcmp

* Clean up include tree

* Remove unneeded headers from PCH files

Removes unneeded headers from pre-compiled headers.  This increases compile time, however reduces development time for most files.

* Update Entity.h

* Update EntityManager.h

* Update GameMessages.cpp

* There it compiles now

Co-authored-by: Aaron Kimbrell <aronwk.aaron@gmail.com>
2023-01-06 23:17:05 -06:00

72 lines
1.7 KiB
C++

#include "RainOfArrows.h"
#include "EntityManager.h"
#include "SkillComponent.h"
#include "EntityInfo.h"
#include "GameMessages.h"
void RainOfArrows::OnStartup(Entity* self) {
}
void RainOfArrows::OnRebuildComplete(Entity* self, Entity* target) {
auto myPos = self->GetPosition();
auto myRot = self->GetRotation();
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")
);
auto* player = EntityManager::Instance()->GetEntity(
self->GetVar<LWOOBJID>(u"playerID")
);
if (timerName == "ArrowsIncoming") {
if (child == nullptr) {
return;
}
auto* skillComponent = child->GetComponent<SkillComponent>();
if (skillComponent == nullptr) {
return;
}
skillComponent->CalculateBehavior(
m_ArrowSkill,
m_ArrowBehavior,
LWOOBJID_EMPTY,
true,
false,
player != nullptr ? player->GetObjectID() : LWOOBJID_EMPTY
);
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();
}
self->Smash(player != nullptr ? player->GetObjectID() : LWOOBJID_EMPTY);
}
}