mirror of
https://github.com/DarkflameUniverse/DarkflameServer
synced 2024-08-30 18:43:58 +00:00
Fully implemented buff station script
This commit is contained in:
parent
f41e8292e8
commit
b297d21a8d
@ -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<DestroyableComponent>();
|
||||
// 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<SkillComponent>();
|
||||
|
||||
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<LWOOBJID>(u"PlayerId", target->GetObjectID());
|
||||
}
|
||||
|
||||
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;
|
||||
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();
|
||||
}
|
@ -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;
|
||||
};
|
Loading…
Reference in New Issue
Block a user