From 3de2c3bfc63a44672c3ba3ea9eb29cd019e4bb40 Mon Sep 17 00:00:00 2001 From: EmosewaMC <39972741+EmosewaMC@users.noreply.github.com> Date: Sun, 6 Feb 2022 21:32:36 -0800 Subject: [PATCH 1/6] set faction of buff station to 6 --- dScripts/AgSurvivalBuffStation.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/dScripts/AgSurvivalBuffStation.cpp b/dScripts/AgSurvivalBuffStation.cpp index 41a754d6..a9a4b75d 100644 --- a/dScripts/AgSurvivalBuffStation.cpp +++ b/dScripts/AgSurvivalBuffStation.cpp @@ -1,8 +1,13 @@ #include "AgSurvivalBuffStation.h" #include "SkillComponent.h" #include "dLogger.h" +#include "DestroyableComponent.h" void AgSurvivalBuffStation::OnRebuildComplete(Entity* self, Entity* target) { + auto destroyableComponent = self->GetComponent(); + + if (destroyableComponent != nullptr) destroyableComponent->SetFaction(6); + auto skillComponent = self->GetComponent(); if (skillComponent == nullptr) return; From f41e8292e82297c07b07dae74466539d97d571bf Mon Sep 17 00:00:00 2001 From: EmosewaMC <39972741+EmosewaMC@users.noreply.github.com> Date: Sun, 6 Feb 2022 21:34:26 -0800 Subject: [PATCH 2/6] Clarified numbers and added comments --- dScripts/AgSurvivalBuffStation.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dScripts/AgSurvivalBuffStation.cpp b/dScripts/AgSurvivalBuffStation.cpp index a9a4b75d..17f3335d 100644 --- a/dScripts/AgSurvivalBuffStation.cpp +++ b/dScripts/AgSurvivalBuffStation.cpp @@ -5,14 +5,14 @@ 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 if (destroyableComponent != nullptr) destroyableComponent->SetFaction(6); auto skillComponent = self->GetComponent(); if (skillComponent == nullptr) return; - skillComponent->CalculateBehavior(201, 1784, self->GetObjectID()); + skillComponent->CalculateBehavior(skillIdForBuffStation, behaviorIdForBuffStation, self->GetObjectID()); self->AddCallbackTimer(10.0f, [self]() { self->Smash(); 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 3/6] 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 From 204f03fd2a5b51a4a5abf309c9ccc05bca2c5ceb Mon Sep 17 00:00:00 2001 From: EmosewaMC <39972741+EmosewaMC@users.noreply.github.com> Date: Sun, 6 Feb 2022 22:19:23 -0800 Subject: [PATCH 4/6] removed extra function --- dScripts/AgSurvivalBuffStation.cpp | 3 --- dScripts/AgSurvivalBuffStation.h | 1 - 2 files changed, 4 deletions(-) diff --git a/dScripts/AgSurvivalBuffStation.cpp b/dScripts/AgSurvivalBuffStation.cpp index d5d2e442..c893d684 100644 --- a/dScripts/AgSurvivalBuffStation.cpp +++ b/dScripts/AgSurvivalBuffStation.cpp @@ -41,6 +41,3 @@ void AgSurvivalBuffStation::OnTimerDone(Entity* self, std::string timerName) { } 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 8d756c7d..b2beaba6 100644 --- a/dScripts/AgSurvivalBuffStation.h +++ b/dScripts/AgSurvivalBuffStation.h @@ -12,7 +12,6 @@ public: */ 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. From 1122f50c7c7b74195162a3fd4c93ac211f09b0cb Mon Sep 17 00:00:00 2001 From: EmosewaMC <39972741+EmosewaMC@users.noreply.github.com> Date: Tue, 8 Feb 2022 01:55:25 -0800 Subject: [PATCH 5/6] Changed time when buff station spawns --- dScripts/BaseSurvivalServer.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dScripts/BaseSurvivalServer.cpp b/dScripts/BaseSurvivalServer.cpp index 1174f00b..dd9b9365 100644 --- a/dScripts/BaseSurvivalServer.cpp +++ b/dScripts/BaseSurvivalServer.cpp @@ -200,6 +200,7 @@ void BaseSurvivalServer::OnActivityTimerDone(Entity *self, const std::string &na ActivityTimerStop(self, SpawnTickTimer); ActivityTimerStart(self, CoolDownStopTimer, 1, constants.coolDownTime); + ActivateSpawnerNetwork(spawnerNetworks.rewardNetworks); SpawnerReset(spawnerNetworks.baseNetworks, false); SpawnerReset(spawnerNetworks.randomNetworks, false); } else if (name == CoolDownStopTimer) { @@ -302,7 +303,6 @@ void BaseSurvivalServer::StartWaves(Entity *self) { self->SetVar(FirstTimeDoneVariable, true); self->SetVar(MissionTypeVariable, state.players.size() == 1 ? "survival_time_solo" : "survival_time_team"); - ActivateSpawnerNetwork(spawnerNetworks.rewardNetworks); ActivateSpawnerNetwork(spawnerNetworks.smashNetworks); self->SetNetworkVar(WavesStartedVariable, true); self->SetNetworkVar(StartWaveMessageVariable, "Start!"); From e397ed310ed0bcdab1a5adbf38921b8e8a5bece4 Mon Sep 17 00:00:00 2001 From: EmosewaMC <39972741+EmosewaMC@users.noreply.github.com> Date: Tue, 8 Feb 2022 02:02:05 -0800 Subject: [PATCH 6/6] Updated script for teams Updated script to drop buffing items for all members in a team. --- dScripts/AgSurvivalBuffStation.cpp | 31 ++++++++++++++++++++++++++---- 1 file changed, 27 insertions(+), 4 deletions(-) diff --git a/dScripts/AgSurvivalBuffStation.cpp b/dScripts/AgSurvivalBuffStation.cpp index c893d684..01fe3976 100644 --- a/dScripts/AgSurvivalBuffStation.cpp +++ b/dScripts/AgSurvivalBuffStation.cpp @@ -4,6 +4,7 @@ #include "GameMessages.h" #include "SkillComponent.h" #include "dLogger.h" +#include "TeamManager.h" void AgSurvivalBuffStation::OnRebuildComplete(Entity* self, Entity* target) { auto destroyableComponent = self->GetComponent(); @@ -20,12 +21,24 @@ void AgSurvivalBuffStation::OnRebuildComplete(Entity* self, Entity* target) { self->AddTimer("DropArmor", dropArmorTimer); self->AddTimer("DropLife", dropLifeTimer); self->AddTimer("Dropimagination", dropImaginationTimer); - self->SetVar(u"PlayerId", target->GetObjectID()); + // Since all survival players should be on the same team, we get the team. + auto team = TeamManager::Instance()->GetTeam(target->GetObjectID()); + + std::vector builderTeam; + // Not on a team + if (team == nullptr) { + builderTeam.push_back(target->GetObjectID()); + self->SetVar>(u"BuilderTeam", builderTeam); + return; + } + + for (auto memberID : team->members) { + builderTeam.push_back(memberID); + } + self->SetVar>(u"BuilderTeam", builderTeam); } 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; @@ -39,5 +52,15 @@ void AgSurvivalBuffStation::OnTimerDone(Entity* self, std::string timerName) { powerupToDrop = imaginationPowerup; self->AddTimer("Dropimagination", dropImaginationTimer); } - if (target != nullptr) GameMessages::SendDropClientLoot(target, self->GetObjectID(), powerupToDrop, 0, self->GetPosition()); + auto team = self->GetVar>(u"BuilderTeam"); + for (auto memberID : team) { + auto member = EntityManager::Instance()->GetEntity(memberID); + if (member != nullptr && !member->GetIsDead()) { + GameMessages::SendDropClientLoot(member, self->GetObjectID(), powerupToDrop, 0, self->GetPosition()); + } else { + // If player left the team or left early erase them from the team variable. + team.erase(std::find(team.begin(), team.end(), memberID)); + self->SetVar>(u"BuilderTeam", team); + } + } }