mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2025-10-28 03:02:05 +00:00
tested the following are now functional ag buff station tiki torch ve rocket part boxes ns statue property behavior extra items from full inventory hardcore drops (items and coins)
70 lines
2.4 KiB
C++
70 lines
2.4 KiB
C++
#include "AgSurvivalBuffStation.h"
|
|
#include "DestroyableComponent.h"
|
|
#include "EntityManager.h"
|
|
#include "GameMessages.h"
|
|
#include "SkillComponent.h"
|
|
#include "TeamManager.h"
|
|
#include "Loot.h"
|
|
|
|
void AgSurvivalBuffStation::OnQuickBuildComplete(Entity* self, Entity* target) {
|
|
auto destroyableComponent = self->GetComponent<DestroyableComponent>();
|
|
// We set the faction to 1 so that the buff station sees players as friendly targets to buff
|
|
if (destroyableComponent != nullptr) destroyableComponent->SetFaction(1);
|
|
|
|
auto skillComponent = self->GetComponent<SkillComponent>();
|
|
|
|
if (skillComponent != nullptr) skillComponent->CalculateBehavior(skillIdForBuffStation, behaviorIdForBuffStation, self->GetObjectID());
|
|
|
|
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 = Game::entityManager->GetEntity(memberID);
|
|
if (member != nullptr && !member->GetIsDead()) {
|
|
GameMessages::DropClientLoot lootMsg{};
|
|
lootMsg.target = member->GetObjectID();
|
|
lootMsg.ownerID = member->GetObjectID();
|
|
lootMsg.sourceID = self->GetObjectID();
|
|
lootMsg.item = powerupToDrop;
|
|
lootMsg.count = 1;
|
|
lootMsg.spawnPos = self->GetPosition();
|
|
Loot::DropItem(*member, lootMsg, true, true);
|
|
}
|
|
}
|
|
}
|