From b297d21a8de2b134a6ef14c505ffe4f552eca53f Mon Sep 17 00:00:00 2001 From: EmosewaMC <39972741+EmosewaMC@users.noreply.github.com> Date: Sun, 6 Feb 2022 22:15:32 -0800 Subject: [PATCH] Fully implemented buff station script --- dScripts/AgSurvivalBuffStation.cpp | 38 +++++++++++++++++++++++++----- dScripts/AgSurvivalBuffStation.h | 30 +++++++++++++++++++++++ 2 files changed, 62 insertions(+), 6 deletions(-) diff --git a/dScripts/AgSurvivalBuffStation.cpp b/dScripts/AgSurvivalBuffStation.cpp index 17f3335d..d5d2e442 100644 --- a/dScripts/AgSurvivalBuffStation.cpp +++ b/dScripts/AgSurvivalBuffStation.cpp @@ -1,20 +1,46 @@ #include "AgSurvivalBuffStation.h" +#include "DestroyableComponent.h" +#include "EntityManager.h" +#include "GameMessages.h" #include "SkillComponent.h" #include "dLogger.h" -#include "DestroyableComponent.h" void AgSurvivalBuffStation::OnRebuildComplete(Entity* self, Entity* target) { auto destroyableComponent = self->GetComponent(); - // We set the faction to 6 so that the buff station sees players as friendly targets + // We set the faction to 6 so that the buff station sees players as friendly targets to buff if (destroyableComponent != nullptr) destroyableComponent->SetFaction(6); auto skillComponent = self->GetComponent(); - if (skillComponent == nullptr) return; + if (skillComponent != nullptr) skillComponent->CalculateBehavior(skillIdForBuffStation, behaviorIdForBuffStation, self->GetObjectID()); - skillComponent->CalculateBehavior(skillIdForBuffStation, behaviorIdForBuffStation, self->GetObjectID()); - - self->AddCallbackTimer(10.0f, [self]() { + self->AddCallbackTimer(smashTimer, [self]() { self->Smash(); }); + self->AddTimer("DropArmor", dropArmorTimer); + self->AddTimer("DropLife", dropLifeTimer); + self->AddTimer("Dropimagination", dropImaginationTimer); + self->SetVar(u"PlayerId", target->GetObjectID()); } + +void AgSurvivalBuffStation::OnTimerDone(Entity* self, std::string timerName) { + auto targetID = self->GetVar(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()); +} +void AgSurvivalBuffStation::OnDie(Entity* self, Entity* killer) { + //self->CancelAllTimers(); +} \ No newline at end of file diff --git a/dScripts/AgSurvivalBuffStation.h b/dScripts/AgSurvivalBuffStation.h index 0b4d1865..8d756c7d 100644 --- a/dScripts/AgSurvivalBuffStation.h +++ b/dScripts/AgSurvivalBuffStation.h @@ -11,6 +11,8 @@ public: * @param target The target of the self that called this script. */ void OnRebuildComplete(Entity* self, Entity* target) override; + void OnTimerDone(Entity* self, std::string timerName) override; + void OnDie(Entity* self, Entity* killer) override; private: /** * Skill ID for the buff station. @@ -20,4 +22,32 @@ private: * Behavior ID for the buff station. */ uint32_t behaviorIdForBuffStation = 1784; + /** + * Timer for dropping armor. + */ + float dropArmorTimer = 6.0f; + /** + * Timer for dropping life. + */ + float dropLifeTimer = 3.0f; + /** + * Timer for dropping imagination. + */ + float dropImaginationTimer = 4.0f; + /** + * Timer for smashing. + */ + float smashTimer = 25.0f; + /** + * LOT for armor powerup. + */ + LOT armorPowerup = 6431; + /** + * LOT for life powerup. + */ + LOT lifePowerup = 177; + /** + * LOT for imagination powerup. + */ + LOT imaginationPowerup = 935; }; \ No newline at end of file