mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2024-11-22 05:27:19 +00:00
Updated script for teams
Updated script to drop buffing items for all members in a team.
This commit is contained in:
parent
1122f50c7c
commit
e397ed310e
@ -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<DestroyableComponent>();
|
||||
@ -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<LWOOBJID>(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<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) {
|
||||
auto targetID = self->GetVar<LWOOBJID>(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<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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user