mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2024-11-24 06:27:24 +00:00
buffs
This commit is contained in:
parent
1470af99c3
commit
9b3c2f094f
@ -6,7 +6,9 @@
|
|||||||
|
|
||||||
|
|
||||||
void ApplyBuffBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) {
|
void ApplyBuffBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) {
|
||||||
auto* entity = EntityManager::Instance()->GetEntity(branch.target == LWOOBJID_EMPTY ? context->originator : branch.target);
|
branch.target == LWOOBJID_EMPTY ? context->originator : branch.target;
|
||||||
|
if (m_TargetCaster) branch.target = context->originator;
|
||||||
|
auto* entity = EntityManager::Instance()->GetEntity(branch.target);
|
||||||
|
|
||||||
if (entity == nullptr) return;
|
if (entity == nullptr) return;
|
||||||
|
|
||||||
@ -14,11 +16,12 @@ void ApplyBuffBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitS
|
|||||||
|
|
||||||
if (buffComponent == nullptr) return;
|
if (buffComponent == nullptr) return;
|
||||||
|
|
||||||
buffComponent->ApplyBuff(m_BuffId, m_Duration, context->originator, addImmunity, cancelOnDamaged, cancelOnDeath,
|
buffComponent->ApplyBuff(m_BuffId, m_Duration, context->originator, m_AddImmunity, m_ApplyOnTeammates m_CancelOnDamaged, m_CancelOnDeath,
|
||||||
cancelOnLogout, cancelonRemoveBuff, cancelOnUi, cancelOnUnequip, cancelOnZone);
|
m_CancelOnLogout, m_CancelOnRemoveBuff, m_CancelOnUi, m_CancelOnUnequip, m_CancelOnZone, m_CancelOnDamageAbsDone, m_UseRefCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ApplyBuffBehavior::UnCast(BehaviorContext* context, BehaviorBranchContext branch) {
|
void ApplyBuffBehavior::UnCast(BehaviorContext* context, BehaviorBranchContext branch) {
|
||||||
|
if (m_IgnoreUncast) return;
|
||||||
auto* entity = EntityManager::Instance()->GetEntity(branch.target);
|
auto* entity = EntityManager::Instance()->GetEntity(branch.target);
|
||||||
|
|
||||||
if (entity == nullptr) return;
|
if (entity == nullptr) return;
|
||||||
@ -37,12 +40,17 @@ void ApplyBuffBehavior::Calculate(BehaviorContext* context, RakNet::BitStream* b
|
|||||||
void ApplyBuffBehavior::Load() {
|
void ApplyBuffBehavior::Load() {
|
||||||
m_BuffId = GetInt("buff_id");
|
m_BuffId = GetInt("buff_id");
|
||||||
m_Duration = GetFloat("duration_secs");
|
m_Duration = GetFloat("duration_secs");
|
||||||
addImmunity = GetBoolean("add_immunity");
|
m_IgnoreUncast = GetBoolean("ignore_uncast", false);
|
||||||
cancelOnDamaged = GetBoolean("cancel_on_damaged");
|
m_TargetCaster = GetBoolean("target_caster", false);
|
||||||
cancelOnDeath = GetBoolean("cancel_on_death");
|
m_AddImmunity = GetBoolean("add_immunity", false);
|
||||||
cancelOnLogout = GetBoolean("cancel_on_logout");
|
m_ApplyOnTeammates = GetBoolean("apply_on_teammates", false);
|
||||||
cancelonRemoveBuff = GetBoolean("cancel_on_remove_buff");
|
m_CancelOnDamaged = GetBoolean("cancel_on_damaged", false);
|
||||||
cancelOnUi = GetBoolean("cancel_on_ui");
|
m_CancelOnDeath = GetBoolean("cancel_on_death", false);
|
||||||
cancelOnUnequip = GetBoolean("cancel_on_unequip");
|
m_CancelOnLogout = GetBoolean("cancel_on_logout", false);
|
||||||
cancelOnZone = GetBoolean("cancel_on_zone");
|
m_CancelOnRemoveBuff = GetBoolean("cancel_on_remove_buff", false);
|
||||||
|
m_CancelOnUi = GetBoolean("cancel_on_ui", false);
|
||||||
|
m_CancelOnUnequip = GetBoolean("cancel_on_unequip", false);
|
||||||
|
m_CancelOnZone = GetBoolean("cancel_on_zone", false);
|
||||||
|
m_CancelOnDamageAbsDone = GetBoolean("cancel_on_damage_abs_done", false);
|
||||||
|
m_UseRefCount = GetBoolean("use_ref_count", false);
|
||||||
}
|
}
|
||||||
|
@ -7,18 +7,7 @@
|
|||||||
class ApplyBuffBehavior final : public Behavior
|
class ApplyBuffBehavior final : public Behavior
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
int32_t m_BuffId;
|
/*
|
||||||
float m_Duration;
|
|
||||||
bool addImmunity;
|
|
||||||
bool cancelOnDamaged;
|
|
||||||
bool cancelOnDeath;
|
|
||||||
bool cancelOnLogout;
|
|
||||||
bool cancelonRemoveBuff;
|
|
||||||
bool cancelOnUi;
|
|
||||||
bool cancelOnUnequip;
|
|
||||||
bool cancelOnZone;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Inherited
|
* Inherited
|
||||||
*/
|
*/
|
||||||
explicit ApplyBuffBehavior(const uint32_t behaviorId) : Behavior(behaviorId) {
|
explicit ApplyBuffBehavior(const uint32_t behaviorId) : Behavior(behaviorId) {
|
||||||
@ -31,4 +20,21 @@ public:
|
|||||||
void Calculate(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) override;
|
void Calculate(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) override;
|
||||||
|
|
||||||
void Load() override;
|
void Load() override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
int32_t m_BuffId;
|
||||||
|
float m_Duration;
|
||||||
|
bool m_IgnoreUncast;
|
||||||
|
bool m_TargetCaster;
|
||||||
|
bool m_AddImmunity;
|
||||||
|
bool m_ApplyOnTeammates;
|
||||||
|
bool m_CancelOnDamaged;
|
||||||
|
bool m_CancelOnDeath;
|
||||||
|
bool m_CancelOnLogout;
|
||||||
|
bool m_CancelOnRemoveBuff;
|
||||||
|
bool m_CancelOnUi;
|
||||||
|
bool m_CancelOnUnequip;
|
||||||
|
bool m_CancelOnZone;
|
||||||
|
bool m_CancelOnDamageAbsDone;
|
||||||
|
bool m_UseRefCount;
|
||||||
};
|
};
|
||||||
|
@ -21,6 +21,8 @@ BuffComponent::~BuffComponent() {
|
|||||||
|
|
||||||
void BuffComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate, unsigned int& flags) {
|
void BuffComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate, unsigned int& flags) {
|
||||||
if (!bIsInitialUpdate) return;
|
if (!bIsInitialUpdate) return;
|
||||||
|
|
||||||
|
// if we have buffs
|
||||||
if (m_Buffs.empty()) {
|
if (m_Buffs.empty()) {
|
||||||
outBitStream->Write0();
|
outBitStream->Write0();
|
||||||
} else {
|
} else {
|
||||||
@ -29,24 +31,25 @@ void BuffComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUp
|
|||||||
|
|
||||||
for (const auto& buff : m_Buffs) {
|
for (const auto& buff : m_Buffs) {
|
||||||
outBitStream->Write<uint32_t>(buff.first);
|
outBitStream->Write<uint32_t>(buff.first);
|
||||||
outBitStream->Write0();
|
outBitStream->Write(buff.second.time); // time left
|
||||||
outBitStream->Write0();
|
outBitStream->Write(buff.second.cancelOnDeath); // cancel on death
|
||||||
outBitStream->Write0();
|
outBitStream->Write(buff.second.cancelOnZone); // cancel on zone
|
||||||
outBitStream->Write0();
|
outBitStream->Write(buff.second.cancelOnDamaged); // cancel on damage
|
||||||
outBitStream->Write0();
|
outBitStream->Write(buff.second.cancelOnRemoveBuff); // cancel on remove buff
|
||||||
outBitStream->Write0();
|
outBitStream->Write(buff.second.cancelOnUi); // cancel on UI
|
||||||
outBitStream->Write0();
|
outBitStream->Write(buff.second.cancelOnLogout); // cancel on logout
|
||||||
outBitStream->Write0();
|
outBitStream->Write(buff.second.cancelOnUnequip); // cancel on unequip
|
||||||
outBitStream->Write0();
|
outBitStream->Write0(); // cancel on damage asorb ran out
|
||||||
|
|
||||||
outBitStream->Write0();
|
outBitStream->Write0(); // if added by team mate
|
||||||
outBitStream->Write0();
|
// teammate lwoobjid
|
||||||
|
outBitStream->Write0(); //apply on team mate
|
||||||
|
|
||||||
outBitStream->Write<uint32_t>(0);
|
outBitStream->Write(buff.second.refcount); // ref_count
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
outBitStream->Write0();
|
outBitStream->Write0(); // buff immunities
|
||||||
}
|
}
|
||||||
|
|
||||||
void BuffComponent::Update(float deltaTime) {
|
void BuffComponent::Update(float deltaTime) {
|
||||||
@ -82,17 +85,23 @@ void BuffComponent::Update(float deltaTime) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void BuffComponent::ApplyBuff(const int32_t id, const float duration, const LWOOBJID source, bool addImmunity,
|
void BuffComponent::ApplyBuff(const int32_t id, const float duration, const LWOOBJID source,
|
||||||
|
bool addImmunity, bool applyOnTeammates,
|
||||||
bool cancelOnDamaged, bool cancelOnDeath, bool cancelOnLogout, bool cancelOnRemoveBuff,
|
bool cancelOnDamaged, bool cancelOnDeath, bool cancelOnLogout, bool cancelOnRemoveBuff,
|
||||||
bool cancelOnUi, bool cancelOnUnequip, bool cancelOnZone) {
|
bool cancelOnUi, bool cancelOnUnequip, bool cancelOnZone, bool cancelOnDamageAbsDone,
|
||||||
|
bool useRefCount) {
|
||||||
// Prevent buffs from stacking.
|
// Prevent buffs from stacking.
|
||||||
|
|
||||||
if (HasBuff(id)) {
|
if (HasBuff(id)) {
|
||||||
return;
|
if (useRefCount){
|
||||||
|
auto buff = m_Buffs.find(id);
|
||||||
|
} else return;
|
||||||
}
|
}
|
||||||
|
|
||||||
GameMessages::SendAddBuff(const_cast<LWOOBJID&>(m_Parent->GetObjectID()), source, (uint32_t)id,
|
GameMessages::SendAddBuff(const_cast<LWOOBJID&>(m_Parent->GetObjectID()), source, (uint32_t)id,
|
||||||
(uint32_t)duration * 1000, addImmunity, cancelOnDamaged, cancelOnDeath,
|
(uint32_t)duration * 1000, addImmunity, applyOnTeammates, cancelOnDamaged, cancelOnDeath,
|
||||||
cancelOnLogout, cancelOnRemoveBuff, cancelOnUi, cancelOnUnequip, cancelOnZone);
|
cancelOnLogout, cancelOnRemoveBuff, cancelOnUi, cancelOnUnequip, cancelOnZone, cancelOnDamageAbsDone,
|
||||||
|
useRefCount);
|
||||||
|
|
||||||
float tick = 0;
|
float tick = 0;
|
||||||
float stacks = 0;
|
float stacks = 0;
|
||||||
@ -120,7 +129,16 @@ void BuffComponent::ApplyBuff(const int32_t id, const float duration, const LWOO
|
|||||||
buff.stacks = stacks;
|
buff.stacks = stacks;
|
||||||
buff.source = source;
|
buff.source = source;
|
||||||
buff.behaviorID = behaviorID;
|
buff.behaviorID = behaviorID;
|
||||||
|
buff.addImmunity = addImmunity;
|
||||||
|
buff.cancelOnDamaged = cancelOnDamaged;
|
||||||
|
buff.cancelOnDeath = cancelOnDeath;
|
||||||
|
buff.cancelOnLogout = cancelOnLogout;
|
||||||
|
buff.cancelOnRemoveBuff = cancelOnRemoveBuff;
|
||||||
|
buff.cancelOnUi = cancelOnUi;
|
||||||
|
buff.cancelOnUnequip = cancelOnUnequip;
|
||||||
|
buff.cancelOnZone = cancelOnZone;
|
||||||
|
buff.useRefCount = useRefCount;
|
||||||
|
buff.refcount = 1;
|
||||||
m_Buffs.emplace(id, buff);
|
m_Buffs.emplace(id, buff);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -34,6 +34,19 @@ struct Buff
|
|||||||
int32_t stacks = 0;
|
int32_t stacks = 0;
|
||||||
LWOOBJID source = 0;
|
LWOOBJID source = 0;
|
||||||
int32_t behaviorID = 0;
|
int32_t behaviorID = 0;
|
||||||
|
bool addImmunity = false;
|
||||||
|
bool cancelOnDamaged = false;
|
||||||
|
bool cancelOnDeath = false;
|
||||||
|
bool cancelOnLogout = false;
|
||||||
|
bool cancelOnRemoveBuff = false;
|
||||||
|
bool cancelOnDamageAbsDone = false;
|
||||||
|
bool cancelOnUi = false;
|
||||||
|
bool cancelOnUnequip = false;
|
||||||
|
bool cancelOnZone = false;
|
||||||
|
bool useRefCount = false;
|
||||||
|
|
||||||
|
uint32_t refcount = 1
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -63,6 +76,7 @@ public:
|
|||||||
* @param duration the duration of the buff in seconds
|
* @param duration the duration of the buff in seconds
|
||||||
* @param source an optional source entity that cast the buff
|
* @param source an optional source entity that cast the buff
|
||||||
* @param addImmunity client flag
|
* @param addImmunity client flag
|
||||||
|
* @param applyOnTeammates should the buff apply on teammates
|
||||||
* @param cancelOnDamaged client flag to indicate that the buff should disappear when damaged
|
* @param cancelOnDamaged client flag to indicate that the buff should disappear when damaged
|
||||||
* @param cancelOnDeath client flag to indicate that the buff should disappear when dying
|
* @param cancelOnDeath client flag to indicate that the buff should disappear when dying
|
||||||
* @param cancelOnLogout client flag to indicate that the buff should disappear when logging out
|
* @param cancelOnLogout client flag to indicate that the buff should disappear when logging out
|
||||||
@ -70,10 +84,13 @@ public:
|
|||||||
* @param cancelOnUi client flag to indicate that the buff should disappear when interacting with UI
|
* @param cancelOnUi client flag to indicate that the buff should disappear when interacting with UI
|
||||||
* @param cancelOnUnequip client flag to indicate that the buff should disappear when the triggering item is unequipped
|
* @param cancelOnUnequip client flag to indicate that the buff should disappear when the triggering item is unequipped
|
||||||
* @param cancelOnZone client flag to indicate that the buff should disappear when changing zones
|
* @param cancelOnZone client flag to indicate that the buff should disappear when changing zones
|
||||||
|
* @param cancelOnDamageAbsDone cancel if we have done damage absorbtion
|
||||||
|
* @param useRefCount client flag to indicate that the stacks
|
||||||
*/
|
*/
|
||||||
void ApplyBuff(int32_t id, float duration, LWOOBJID source, bool addImmunity = false, bool cancelOnDamaged = false,
|
void ApplyBuff(int32_t id, float duration, LWOOBJID source, bool addImmunity = false, bool applyOnTeammates = false,
|
||||||
bool cancelOnDeath = true, bool cancelOnLogout = false, bool cancelOnRemoveBuff = true,
|
bool cancelOnDamaged = false, bool cancelOnDeath = true, bool cancelOnLogout = false, bool cancelOnRemoveBuff = true,
|
||||||
bool cancelOnUi = false, bool cancelOnUnequip = false, bool cancelOnZone = false);
|
bool cancelOnUi = false, bool cancelOnUnequip = false, bool cancelOnZone = false, bool cancelOnDamageAbsDone = false,
|
||||||
|
bool useRefCount = false);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Removes a buff from the parent entity, reversing its effects
|
* Removes a buff from the parent entity, reversing its effects
|
||||||
|
@ -4438,8 +4438,10 @@ void GameMessages::SendVehicleNotifyFinishedRace(LWOOBJID objectId, const System
|
|||||||
}
|
}
|
||||||
|
|
||||||
void GameMessages::SendAddBuff(LWOOBJID& objectID, const LWOOBJID& casterID, uint32_t buffID, uint32_t msDuration,
|
void GameMessages::SendAddBuff(LWOOBJID& objectID, const LWOOBJID& casterID, uint32_t buffID, uint32_t msDuration,
|
||||||
bool addImmunity, bool cancelOnDamaged, bool cancelOnDeath, bool cancelOnLogout,
|
bool addImmunity, bool applyOnTeammates,
|
||||||
bool cancelOnRemoveBuff, bool cancelOnUi, bool cancelOnUnequip, bool cancelOnZone,
|
bool cancelOnDamaged, bool cancelOnDeath, bool cancelOnLogout, bool cancelOnRemoveBuff,
|
||||||
|
bool cancelOnUi, bool cancelOnUnequip, bool cancelOnZone, bool cancelOnDamageAbsDone,
|
||||||
|
bool useRefCount,
|
||||||
const SystemAddress& sysAddr) {
|
const SystemAddress& sysAddr) {
|
||||||
CBITSTREAM;
|
CBITSTREAM;
|
||||||
CMSGHEADER;
|
CMSGHEADER;
|
||||||
@ -4448,8 +4450,8 @@ void GameMessages::SendAddBuff(LWOOBJID& objectID, const LWOOBJID& casterID, uin
|
|||||||
bitStream.Write(GAME_MSG::GAME_MSG_ADD_BUFF);
|
bitStream.Write(GAME_MSG::GAME_MSG_ADD_BUFF);
|
||||||
|
|
||||||
bitStream.Write(false); // Added by teammate
|
bitStream.Write(false); // Added by teammate
|
||||||
bitStream.Write(false); // Apply on teammates
|
bitStream.Write(applyOnTeammates);
|
||||||
bitStream.Write(false); // Cancel on damage absorb ran out
|
bitStream.Write(cancelOnDamageAbsDone);
|
||||||
bitStream.Write(cancelOnDamaged);
|
bitStream.Write(cancelOnDamaged);
|
||||||
bitStream.Write(cancelOnDeath);
|
bitStream.Write(cancelOnDeath);
|
||||||
bitStream.Write(cancelOnLogout);
|
bitStream.Write(cancelOnLogout);
|
||||||
@ -4461,7 +4463,7 @@ void GameMessages::SendAddBuff(LWOOBJID& objectID, const LWOOBJID& casterID, uin
|
|||||||
bitStream.Write(cancelOnZone);
|
bitStream.Write(cancelOnZone);
|
||||||
bitStream.Write(false); // Ignore immunities
|
bitStream.Write(false); // Ignore immunities
|
||||||
bitStream.Write(addImmunity);
|
bitStream.Write(addImmunity);
|
||||||
bitStream.Write(false); // Use ref count
|
bitStream.Write(useRefCount);
|
||||||
|
|
||||||
bitStream.Write(buffID);
|
bitStream.Write(buffID);
|
||||||
bitStream.Write(msDuration);
|
bitStream.Write(msDuration);
|
||||||
|
@ -184,9 +184,11 @@ namespace GameMessages {
|
|||||||
void SendBBBSaveResponse(const LWOOBJID& objectId, const LWOOBJID& localID, unsigned char* buffer, uint32_t bufferSize, const SystemAddress& sysAddr);
|
void SendBBBSaveResponse(const LWOOBJID& objectId, const LWOOBJID& localID, unsigned char* buffer, uint32_t bufferSize, const SystemAddress& sysAddr);
|
||||||
|
|
||||||
void SendAddBuff(LWOOBJID& objectID, const LWOOBJID& casterID, uint32_t buffID, uint32_t msDuration,
|
void SendAddBuff(LWOOBJID& objectID, const LWOOBJID& casterID, uint32_t buffID, uint32_t msDuration,
|
||||||
bool addImmunity = false, bool cancelOnDamaged = false, bool cancelOnDeath = true,
|
bool addImmunity = false, bool applyOnTeammates = false,
|
||||||
bool cancelOnLogout = false, bool cancelOnRemoveBuff = true, bool cancelOnUi = false,
|
bool cancelOnDamaged = false, bool cancelOnDeath = true,bool cancelOnLogout = false, bool cancelOnRemoveBuff = true,
|
||||||
bool cancelOnUnequip = false, bool cancelOnZone = false, const SystemAddress& sysAddr = UNASSIGNED_SYSTEM_ADDRESS);
|
bool cancelOnUi = false, bool cancelOnUnequip = false, bool cancelOnZone = false, bool cancelOnDamageAbsDone = false,
|
||||||
|
bool useRefCount = false,
|
||||||
|
const SystemAddress& sysAddr = UNASSIGNED_SYSTEM_ADDRESS);
|
||||||
|
|
||||||
void SendToggleGMInvis(LWOOBJID objectId, bool enabled, const SystemAddress& sysAddr);
|
void SendToggleGMInvis(LWOOBJID objectId, bool enabled, const SystemAddress& sysAddr);
|
||||||
|
|
||||||
|
@ -194,7 +194,7 @@ void AuthPackets::SendLoginResponse(dServer* server, const SystemAddress& sysAdd
|
|||||||
PacketUtils::WritePacketString("Talk_Like_A_Pirate", 33, &packet);
|
PacketUtils::WritePacketString("Talk_Like_A_Pirate", 33, &packet);
|
||||||
|
|
||||||
// 7 unknown strings - perhaps other IP addresses?
|
// 7 unknown strings - perhaps other IP addresses?
|
||||||
PacketUtils::WritePacketString("", 33, &packet);
|
PacketUtils::WritePacketString("ninjago2", 33, &packet);
|
||||||
PacketUtils::WritePacketString("", 33, &packet);
|
PacketUtils::WritePacketString("", 33, &packet);
|
||||||
PacketUtils::WritePacketString("", 33, &packet);
|
PacketUtils::WritePacketString("", 33, &packet);
|
||||||
PacketUtils::WritePacketString("", 33, &packet);
|
PacketUtils::WritePacketString("", 33, &packet);
|
||||||
|
Loading…
Reference in New Issue
Block a user