Merge pull request #442 from EmosewaMC/AvantGardensSurvivalBuffStation

Fully implemented Avant Gardens Survival Buff Station
This commit is contained in:
Jett 2022-03-30 22:22:50 +01:00 committed by GitHub
commit ff9d736073
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 85 additions and 5 deletions

View File

@ -1,15 +1,66 @@
#include "AgSurvivalBuffStation.h"
#include "DestroyableComponent.h"
#include "EntityManager.h"
#include "GameMessages.h"
#include "SkillComponent.h"
#include "dLogger.h"
#include "TeamManager.h"
void AgSurvivalBuffStation::OnRebuildComplete(Entity* self, Entity* target) {
auto destroyableComponent = self->GetComponent<DestroyableComponent>();
// 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<SkillComponent>();
if (skillComponent == nullptr) return;
if (skillComponent != nullptr) skillComponent->CalculateBehavior(skillIdForBuffStation, behaviorIdForBuffStation, self->GetObjectID());
skillComponent->CalculateBehavior(201, 1784, 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);
// Since all survival players should be on the same team, we get the team.
auto team = TeamManager::Instance()->GetTeam(target->GetObjectID());
std::vector<LWOOBJID> builderTeam;
// Not on a team
if (team == nullptr) {
builderTeam.push_back(target->GetObjectID());
self->SetVar<std::vector<LWOOBJID>>(u"BuilderTeam", builderTeam);
return;
}
for (auto memberID : team->members) {
builderTeam.push_back(memberID);
}
self->SetVar<std::vector<LWOOBJID>>(u"BuilderTeam", builderTeam);
}
void AgSurvivalBuffStation::OnTimerDone(Entity* self, std::string timerName) {
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);
}
auto team = self->GetVar<std::vector<LWOOBJID>>(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<std::vector<LWOOBJID>>(u"BuilderTeam", team);
}
}
}

View File

@ -11,6 +11,7 @@ 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;
private:
/**
* Skill ID for the buff station.
@ -20,4 +21,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;
};

View File

@ -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<bool>(FirstTimeDoneVariable, true);
self->SetVar<std::string>(MissionTypeVariable, state.players.size() == 1 ? "survival_time_solo" : "survival_time_team");
ActivateSpawnerNetwork(spawnerNetworks.rewardNetworks);
ActivateSpawnerNetwork(spawnerNetworks.smashNetworks);
self->SetNetworkVar<bool>(WavesStartedVariable, true);
self->SetNetworkVar<std::string>(StartWaveMessageVariable, "Start!");