DarkflameServer/dScripts/AgSurvivalBuffStation.cpp

44 lines
1.8 KiB
C++
Raw Normal View History

#include "AgSurvivalBuffStation.h"
2022-02-07 06:15:32 +00:00
#include "DestroyableComponent.h"
#include "EntityManager.h"
#include "GameMessages.h"
#include "SkillComponent.h"
#include "dLogger.h"
void AgSurvivalBuffStation::OnRebuildComplete(Entity* self, Entity* target) {
2022-02-07 05:32:36 +00:00
auto destroyableComponent = self->GetComponent<DestroyableComponent>();
2022-02-07 06:15:32 +00:00
// We set the faction to 6 so that the buff station sees players as friendly targets to buff
2022-02-07 05:32:36 +00:00
if (destroyableComponent != nullptr) destroyableComponent->SetFaction(6);
auto skillComponent = self->GetComponent<SkillComponent>();
2022-02-07 06:15:32 +00:00
if (skillComponent != nullptr) skillComponent->CalculateBehavior(skillIdForBuffStation, behaviorIdForBuffStation, self->GetObjectID());
2022-02-07 06:15:32 +00:00
self->AddCallbackTimer(smashTimer, [self]() {
self->Smash();
2022-01-21 00:00:45 +00:00
});
2022-02-07 06:15:32 +00:00
self->AddTimer("DropArmor", dropArmorTimer);
self->AddTimer("DropLife", dropLifeTimer);
self->AddTimer("Dropimagination", dropImaginationTimer);
self->SetVar<LWOOBJID>(u"PlayerId", target->GetObjectID());
}
void AgSurvivalBuffStation::OnTimerDone(Entity* self, std::string timerName) {
auto targetID = self->GetVar<LWOOBJID>(u"PlayerId");
auto target = EntityManager::Instance()->GetEntity(targetID);
uint32_t powerupToDrop = lifePowerup;
if (timerName == "DropArmor") {
powerupToDrop = armorPowerup;
self->AddTimer("DropArmor", dropArmorTimer);
}
if (timerName == "DropLife") {
powerupToDrop = lifePowerup;
self->AddTimer("DropLife", dropLifeTimer);
}
if (timerName == "Dropimagination") {
powerupToDrop = imaginationPowerup;
self->AddTimer("Dropimagination", dropImaginationTimer);
}
if (target != nullptr) GameMessages::SendDropClientLoot(target, self->GetObjectID(), powerupToDrop, 0, self->GetPosition());
2022-01-21 00:00:45 +00:00
}